Skip to content

Add a Retry-After header to 429 responses from rateLimiterΒ #82

Description

@Jagadeeshftw

πŸ“Œ Description

middleware/rateLimiter.ts returns 429 RATE_LIMITED when a client exceeds the per-IP window, but per the current README it doesn't mention a Retry-After header β€” clients have to guess when to retry instead of being told the remaining window.

🧩 Requirements and context

  • Compute seconds remaining in the current window and set Retry-After on every 429 response, for both the general limiter and the stricter quote limiter.
  • Value should be accurate to within one second of the actual window reset.
  • No change to the 429 body shape.

πŸ› οΈ Suggested execution

  • Update rateLimiter() in middleware/rateLimiter.ts to compute and set the header from the bucket's window state.
  • Add tests in middleware/rateLimiter.test.ts asserting the header is present and numerically sane on a 429.
  • Mention the header in the README's rate-limiting section.

βœ… Acceptance criteria

  • Every 429 response includes a Retry-After header.
  • Header value is accurate relative to the window reset.
  • Documented in README.

πŸ”’ Security notes

No new attack surface; slightly improves client-side backoff behavior which indirectly reduces load spikes.

πŸ“‹ Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issueapiHTTP/WebSocket APIenhancementNew feature or improvement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions