Fix Galaxy Store hang by timing out transaction lookup#436
Merged
Conversation
When a custom PurchaseController completes a purchase on a non-Play store (e.g. Galaxy Store), Google Play Billing never fires onPurchasesUpdated, so getLatestTransaction() suspended forever on the purchaseResults StateFlow. Paywall purchases then never resolved: no transaction_complete, no dismissal, spinner stuck indefinitely. - Bound the wait with a 5s timeout when an external purchase controller is in use; the controller's result is the source of truth and the Play transaction only enriches tracking events, so fall back to null. - Clear the retained purchaseResults value when a purchase starts so a purchase can't be resolved against a stale transaction from an earlier one (StateFlow retains the last emission indefinitely). - Remove a redundant duplicate getLatestTransaction() await in the external purchase path. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YTvfzggPBxHokZmZdauvwo
prepareToPurchase now clears billing.purchaseResults at purchase start, which the strict mock in the androidTest TransactionManagerTest didn't stub, failing internal purchase tests with MockKException. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YTvfzggPBxHokZmZdauvwo
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.
Changes in this pull request
awaitLatestTransaction()helper method that centralizes transaction verification across multiple call sitesTechnical Details
The Galaxy Store integration issue occurred because:
onPurchasesUpdated()getLatestTransaction()without timeout, causing indefinite suspensionThe fix introduces:
awaitLatestTransaction()method that wraps transaction lookup with a 5-second timeout when an external purchase controller is presentnulltransaction if timeout occurs (safe since transactions only enrich tracking events)purchaseResultsbefore new purchases to prevent stale transaction matchingTest Coverage
Added
purchase_internalWithExternalControllerAndNoPlayResult_completesWithoutHanging()test that:PurchaseControllercompletes purchase outside PlaygetLatestTransaction()never returningnulltransactionChecklist
https://claude.ai/code/session_01YTvfzggPBxHokZmZdauvwo