Repository navigation
fix(cash-link): show already collected when a claim loses the race - #1184
Merged
Merged
Conversation
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.
When two users claim the same cash link at once, the loser sees "Something Went Wrong / Please try again later" and the claim is reported to Bugsnag. Retrying then shows "Cash Already Collected". The server confirmed why: the losing claim fails in its database transaction commit and returns gRPC INTERNAL (
ErrorSubmitIntent.grpcStatus(13), "rpc server failure") instead ofstaleState(alreadyClaimed), soSession.receiveCashLinklands in its catch-all.Bugsnag group 6a7b33b has 223 events from 37 users; 216 are on the claim (
client.receiveCashLink) and 7 oncreateAccounts. This is item work fromdocs/specs/bugsnag-cleanup.md(code-payments/flipcash-client-orchestrator#91).When the claim submit throws INTERNAL,
CashLinkClaimRace.lostClaimre-fetches the gift card account info. IfclaimStateis.claimed,SessionthrowsstaleState([], kinds: [.alreadyClaimed]), so the existing already-claimed catch handles it: info log,cashLinkClaims.record(collected: false), the "Cash Already Collected" dialog, and analytics withsuccessful: false, with noErrorReporting.captureError. Any other claim state, or a failed re-fetch, rethrows the original INTERNAL error into the catch-all unchanged. INTERNAL fromcreateAccountsor elsewhere is untouched.This is interim. Once the server returns STALE_STATE for the losing claim, the re-fetch can be removed.
Sessiontakes a concreteClient, soreceiveCashLinkcan't be driven in a unit test. The decision lives inCashLinkClaimRace, which takes the existingGiftCardAccountReadingprotocol, andRegression_6a7b33bcovers it: claimed, not claimed, re-fetch throws, and non-INTERNAL errors (which never re-fetch).