feat(http/unstable): add parseRetryAfter - #7299
Open
tomas-zijdemans wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7299 +/- ##
==========================================
+ Coverage 95.03% 95.05% +0.01%
==========================================
Files 617 619 +2
Lines 51637 52030 +393
Branches 9359 9431 +72
==========================================
+ Hits 49075 49455 +380
- Misses 2021 2030 +9
- Partials 541 545 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Aug 23, 2026
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.
Adds
parseRetryAfterto@std/httpas an unstable API. It turns aRetry-Afterheader value into milliseconds to wait, so a retry loop after a 429 or 503 can honor the server instead of guessing.Implements the parser half of #7296. The predicate half is #7298.
What it does
delta-secondsand all three RFC 9110 HTTP-date forms: IMF-fixdate, RFC 850, and asctime.now, clamped to0for past dates. Returnsnullfor anything invalid. Never throws.Date.parseon purpose: it accepts junk like"-1"and" 120"and silently normalizes invalid calendar dates. Each grammar is matched exactly, with calendar and weekday validation.Worth a close look
60normalizes to the following instant, since JSDatecannot represent it.Scope
This PR only parses the field. Emitting
Retry-Afterbelongs to the server-side rate-limiting work in #7237. Honoring it inside@std/asyncretry()is a separate upcoming proposal. Nothing here touches@std/async.Testing
23 tests with fixed
nowvalues and GMT dates: all three date forms, both sides of the 50-year boundary, a leap second, overflow, and a pile of near-miss syntax.deno task okand the Node cross-runtime runner pass.