Skip to content

fix(cash-link): show already collected when a claim loses the race - #1184

Merged
bmc08gt merged 2 commits into
mainfrom
fix/cash-link-race-loser
Oct 31, 2026
Merged

bmc08gt merged 2 commits into
mainfrom
fix/cash-link-race-loser

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

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 of staleState(alreadyClaimed), so Session.receiveCashLink lands in its catch-all.

Bugsnag group 6a7b33b has 223 events from 37 users; 216 are on the claim (client.receiveCashLink) and 7 on createAccounts. This is item work from docs/specs/bugsnag-cleanup.md (code-payments/flipcash-client-orchestrator#91).

When the claim submit throws INTERNAL, CashLinkClaimRace.lostClaim re-fetches the gift card account info. If claimState is .claimed, Session throws staleState([], kinds: [.alreadyClaimed]), so the existing already-claimed catch handles it: info log, cashLinkClaims.record(collected: false), the "Cash Already Collected" dialog, and analytics with successful: false, with no ErrorReporting.captureError. Any other claim state, or a failed re-fetch, rethrows the original INTERNAL error into the catch-all unchanged. INTERNAL from createAccounts or elsewhere is untouched.

This is interim. Once the server returns STALE_STATE for the losing claim, the re-fetch can be removed.

Session takes a concrete Client, so receiveCashLink can't be driven in a unit test. The decision lives in CashLinkClaimRace, which takes the existing GiftCardAccountReading protocol, and Regression_6a7b33b covers it: claimed, not claimed, re-fetch throws, and non-INTERNAL errors (which never re-fetch).

@bmc08gt bmc08gt self-assigned this Oct 31, 2026
@bmc08gt
bmc08gt merged commit f4c3c9b into main Oct 31, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant