Skip to content

fix(api): parse HTTP-date in Retry-After and eliminate unreachable rate-limit fallback (#572) - #586

Open
Proxima84-code wants to merge 1 commit into
MergeFi:mainfrom
Proxima84-code:fix/api-request-429-retry-after
Open

Proxima84-code wants to merge 1 commit into
MergeFi:mainfrom
Proxima84-code:fix/api-request-429-retry-after

Conversation

@Proxima84-code

Copy link
Copy Markdown

Summary

Fixes #572.

In apiRequest 429 response handling:

  1. RFC 9110 HTTP-date support: parseInt was failing when Retry-After contained standard HTTP-date timestamps (e.g. Retry-After: Wed, 21 Oct 2026 07:28:00 GMT), evaluating to NaN and losing retry throttle delays.
  2. Dead code removal: The template literal on the left side of || always evaluated to truthy, rendering the fallback message Rate limited. Please try again later. unreachable.

Changes

  • Added and exported parseRetryAfter in src/lib/api.ts handling delay-seconds (/^\d+$/) and HTTP-dates via Date.parse.
  • Structured error message selection to explicitly use countdown formatting when seconds are defined, or generic rate-limit text otherwise.
  • Added comprehensive unit tests in src/lib/api.test.ts verifying delay-seconds, HTTP-dates, missing headers, and malformed strings.

@vercel

vercel Bot commented Oct 6, 2026

Copy link
Copy Markdown

@Proxima84-code is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

apiRequest's 429 handling ignores Retry-After in HTTP-date form, and its || "Rate limited..." fallback message is dead code

1 participant