fix(payment): retry transient payment-history fetch errors (#162)#165
Merged
Conversation
payment-isolation.spec.ts:113 went red on all 3 browsers on main after #156 shifted session/redirect timing. Root cause (reproduced): under concurrent CI backend load, getPaymentHistory()'s first attempt can hit a transient Realtime/RLS 401/406 during session hydration and throw. The component then rendered a THIRD terminal state — the 'Error loading payment history' alert — which is neither the empty-state heading nor a [data-payment-item], so the test's hasNoPayments||hasPayments assertion was false. Locally (uncontended backend) the test passes 9/9, confirming it's load-sensitivity, not broken logic. Fix (root cause, helps prod too): PaymentHistory.refetch now retries a failed fetch up to 3x with linear backoff (300/600ms) before surfacing the error alert — a momentary blip no longer strands the user on an error screen. The E2E assertion is also made resilient: expect.poll for a stable terminal state instead of asserting on the first post-loading frame, so it never races the retry window. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
Fixes #162 —
payment-isolation.spec.ts:113red on all 3 browsers onmain.Root cause (reproduced): under concurrent CI backend load,
getPaymentHistory()'s first attempt hits a transient Realtime/RLS 401/406 during session hydration and throws.PaymentHistorythen renders a third terminal state — the "Error loading payment history" alert — which is neither the empty-state heading nor a[data-payment-item], soexpect(hasNoPayments || hasPayments).toBe(true)fails. Locally (uncontended backend) the test passes 9/9, confirming load-sensitivity, not broken logic. #156's session/redirect timing change made this pre-existing contention newly visible.Fix (root cause, helps prod too):
PaymentHistory.refetchretries a failed fetch up to 3× with linear backoff (300/600ms) before surfacing the error alert — a momentary blip no longer strands the user on an error screen.expect.pollfor a stable terminal state instead of asserting on the first post-loading frame, so it never races the retry window.Verification
pnpm run type-checkclean; prettier cleanpayment-isolation:113locally: 6/6 with--repeat-each=5🤖 Generated with Claude Code