Conversation
…andler (MergeFi#572) - Parse Retry-After as delay-seconds OR an RFC 9110 HTTP-date; previously parseInt() dropped the date form so callers reading retryAfter got undefined. - Remove the dead `|| 'Rate limited...'` fallback (the left operand is always truthy), restoring the intended 'no wait info' message. - Add unit tests for delay-seconds, HTTP-date, missing, and garbage headers. Fixes MergeFi#572
|
@foxxx009 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #572.
What's wrong
apiRequest's 429 handler parsesRetry-AfterwithparseInt(), which only understands the delay-seconds form. Per RFC 9110 the header may also be an HTTP-date (Retry-After: Wed, 21 Oct 2026 07:28:00 GMT); with that formparseIntyieldsNaN, soretryAftersurfaced to callers isundefinedand they can't honour the backoff.The error message also has a dead fallback:
`You're doing that too fast.${waitMsg}` || `Rate limited...`— the left operand is a template literal and always truthy, so the second branch never runs.What changed
parseRetryAfter()now accepts both RFC 9110 forms: delay-seconds (/^\d+$/) and HTTP-date (Date.parse→Math.max(0, ceil((date - now)/1000))). Garbage values still yieldundefined.||fallback and made the two messages explicit: with wait info vs. without.Verification
jest src/lib/api.test.ts— 10/10 pass (4 new).main(the 3 pre-existing failing suites are untouched by this change).eslint src/lib/api.ts src/lib/api.test.ts— clean.