Category: Functional Edge Case
Repository location: apps/web/lib/api.ts, apps/web/hooks/useInvoices.ts, apps/web/hooks/usePool.ts, apps/web/hooks/useProfile.ts
Problem
apiFetch special-cases 503/504 with a friendlier "Service Temporarily Unavailable, try again later" message, but no mutation hook (useMutation calls in useInvoices.ts, usePool.ts, useProfile.ts) sets a retry option, and react-query's mutation default is retry: 0. A transient gateway blip on createInvoice, deposit, withdraw, repayInvoice, etc. fails immediately with no automatic recovery, despite the UI copy implying the user should just wait and retry.
Evidence
Grep of apps/web/hooks/*.ts shows no retry: option on any useMutation call; apiFetch's 503/504 branch in apps/web/lib/api.ts (~lines 82-98) only changes the message, not the retry behavior.
Suggested implementation
Add bounded retry with backoff (e.g. retry: 2, retryDelay: exponential) for idempotent mutations, or at minimum surface an explicit "Retry" button in the mutation's error toast that re-invokes mutate with the same variables.
Acceptance criteria
- A mutation that fails with a 503 automatically retries up to N times with backoff before surfacing an error to the user.
- A test simulates a 503-then-200 sequence and asserts the mutation ultimately succeeds without user interaction.
Difficulty: Medium
Expected impact: Reduces user-visible failures caused by transient backend/RPC blips on money-moving actions.
Filed as part of the second repository-wide audit (deeper refinements following the first cleanup pass).
Category: Functional Edge Case
Repository location: apps/web/lib/api.ts, apps/web/hooks/useInvoices.ts, apps/web/hooks/usePool.ts, apps/web/hooks/useProfile.ts
Problem
apiFetchspecial-cases 503/504 with a friendlier "Service Temporarily Unavailable, try again later" message, but no mutation hook (useMutationcalls inuseInvoices.ts,usePool.ts,useProfile.ts) sets aretryoption, and react-query's mutation default isretry: 0. A transient gateway blip oncreateInvoice,deposit,withdraw,repayInvoice, etc. fails immediately with no automatic recovery, despite the UI copy implying the user should just wait and retry.Evidence
Grep of
apps/web/hooks/*.tsshows noretry:option on anyuseMutationcall;apiFetch's 503/504 branch inapps/web/lib/api.ts(~lines 82-98) only changes the message, not the retry behavior.Suggested implementation
Add bounded retry with backoff (e.g.
retry: 2, retryDelay: exponential) for idempotent mutations, or at minimum surface an explicit "Retry" button in the mutation's error toast that re-invokesmutatewith the same variables.Acceptance criteria
Difficulty: Medium
Expected impact: Reduces user-visible failures caused by transient backend/RPC blips on money-moving actions.
Filed as part of the second repository-wide audit (deeper refinements following the first cleanup pass).