Skip to content

No retry policy exists for financial mutations, so a single transient 503 fails the whole flow #639

Description

@K1NGD4VID

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programenhancementNew feature or requestfrontendNext.js Web Application

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions