Skip to content

fix(payment): retry transient payment-history fetch errors (#162)#165

Merged
TortoiseWolfe merged 1 commit into
mainfrom
fix/payment-history-transient-retry
Jul 4, 2026
Merged

fix(payment): retry transient payment-history fetch errors (#162)#165
TortoiseWolfe merged 1 commit into
mainfrom
fix/payment-history-transient-retry

Conversation

@TortoiseWolfe

Copy link
Copy Markdown
Owner

Summary

Fixes #162payment-isolation.spec.ts:113 red on all 3 browsers on main.

Root cause (reproduced): under concurrent CI backend load, getPaymentHistory()'s first attempt hits a transient Realtime/RLS 401/406 during session hydration and throws. PaymentHistory then renders a third terminal state — the "Error loading payment history" alert — which is neither the empty-state heading nor a [data-payment-item], so expect(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.refetch retries 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.
  • The E2E assertion uses expect.poll for a stable terminal state instead of asserting on the first post-loading frame, so it never races the retry window.

Verification

  • pnpm run type-check clean; prettier clean
  • PaymentHistory unit tests (8) green
  • payment-isolation:113 locally: 6/6 with --repeat-each=5
  • CI is the real judge — the failure only manifests under concurrent-backend load, which can't be fully reproduced locally. This PR's E2E run against the shared backend is the true test.

🤖 Generated with Claude Code

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>
@TortoiseWolfe TortoiseWolfe merged commit f65439e into main Jul 4, 2026
18 checks passed
@TortoiseWolfe TortoiseWolfe deleted the fix/payment-history-transient-retry branch July 4, 2026 00:11
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.

main red: payment-isolation.spec.ts:113 fails on all 3 browsers after #156 auth-redirect change

2 participants