Skip to content

API Rate-Limit Exceeded Feedback with Retry Countdown #517

Description

@Kingsman-99

Description

When the dApp's backend API rate-limits any request (not just invoice creation), the frontend surfaces a generic network error rather than explaining the situation and automatically retrying. A unified rate-limit handler with countdown and auto-retry should apply to all API calls across the application.

Technical Context

src/lib/api.ts (new or refactored) is a central fetch wrapper that intercepts 429 responses, reads the Retry-After header, and schedules an automatic retry using setTimeout. src/context/RateLimitContext.tsx (new) tracks the global rate-limit state and exposes it to src/components/layout/RateLimitBar.tsx (new), which renders a slim banner at the top of the page showing the countdown. Individual hooks in src/hooks/ use the central api wrapper instead of raw fetch.

Acceptance Criteria

  • Any API call across the app that receives a 429 response triggers the rate-limit banner with a countdown
  • The API wrapper automatically retries the failed request when the countdown reaches zero
  • The banner is dismissable but the auto-retry still proceeds even when dismissed
  • Only one banner instance is shown even if multiple concurrent requests hit the rate limit simultaneously
  • Successful auto-retry resolves the original Promise and updates the UI as if the first call had succeeded
  • All CI checks (npm test, npm run build, ESLint/TypeScript) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions