Repository navigation
fix(blockstore): add timeout and cancellation handling to Block Store calls - #4645
Closed
sahuadarsh0 wants to merge 1 commit into
Closed
sahuadarsh0 wants to merge 1 commit into
sahuadarsh0 wants to merge 1 commit into
Conversation
Contributor
|
Hi @sahuadarsh0, sorry for the delay and thanks for the contribution! While we haven't been able to reproduce the original issue, we think this is safe so we've merged it in our internal repo and it's part of 06899c0. This will be part of our next release which will ship soon, so will close this. @prilaga sorry to hear you're experiencing this. It would be great if you could provide more details on how often you're facing this, since it's been difficult to reproduce this and we would consider this an edge case, so we want to make sure you're experiencing this same issue. Feel free to contact us in our support page. |
4 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
purchases-iosand hybridsMotivation
Resolves #4643
PurchasesOrchestratorwaits onBlockstoreHelper.aliasCurrentAndStoredUserIdsIfNeededbefore dispatching purchase callbacks and restore queries, and waits onBlockstoreHelper.clearUserIdBackupIfNeededinsiderunIdentityOperationbefore callingidentityManager.logIn. Previously,retrieveBytes,deleteBytes, andstoreByteswaited indefinitely on Play ServicesTaskcallbacks with no timeout and noOnCanceledListener, so a stalled or canceled Task left purchase callbacks unsettled and could block subsequent identity operations.Description
Task<T>.awaitWithTimeout()helper inBlockstoreHelperthat wrapssuspendCancellableCoroutineinwithTimeout(blockstoreTimeout)(default5.seconds) and handlesaddOnCanceledListeneralongside success and failure listeners.getBlockstoreData,storeUserIdIfNeeded, andclearUserIdBackupIfNeededto useawaitWithTimeout(), logging timeouts and falling through to the existing completion callback once (with late Task completions ignored bysafeResume), while rethrowing non-timeoutCancellationException.BlockstoreHelperTestcovering timeout (including late completion after timeout) and Task cancellation for bothaliasCurrentAndStoredUserIdsIfNeededandclearUserIdBackupIfNeeded.Testing
./gradlew :purchases:testDefaultsDebugUnitTest --tests "com.revenuecat.purchases.blockstore.BlockstoreHelperTest" --tests "com.revenuecat.purchases.common.LogInReadTimeoutTest" detektAll(all 23 tests anddetektAllpassed)./gradlew :purchases:compileCustomEntitlementComputationDebugKotlin(passed)Note
Medium Risk
Touches gating for purchase callbacks and pre-login Block Store cleanup in
PurchasesOrchestrator; behavior change is bounded timeouts with graceful fallback rather than new identity rules.Overview
Adds a 5-second timeout around all Google Play Block Store
Taskawaits via a newTask.awaitWithTimeout()helper, and wires cancellation throughOnCanceledListenerso stalled or canceled Play Services tasks no longer hang identity/purchase flows indefinitely.retrieveBytes,storeBytes, anddeleteBytesnow go through that helper; timeout and cancel paths log and continue (e.g. still invoke completion callbacks once for alias/clear), while non-timeoutCancellationExceptionis rethrown. Unit tests mock cancel listeners and assert single callback on timeout, including late task completion after timeout.Reviewed by Cursor Bugbot for commit ff9fb66. Bugbot is set up for automated code reviews on this repo. Configure here.