feat(http/unstable): add isRetriableFetchError - #7298
Open
tomas-zijdemans wants to merge 2 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7298 +/- ##
=======================================
Coverage 95.03% 95.04%
=======================================
Files 617 618 +1
Lines 51637 51698 +61
Branches 9359 9381 +22
=======================================
+ Hits 49075 49136 +61
Misses 2021 2021
Partials 541 541 ☔ 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
isRetriableFetchError, the missing predicate forretry()'sisRetriablehook. It recognizes transient fetch failures without substring-matching arbitrary error messages.Implements the predicate half of #7296. The parser half is #7299.
Retriable cases
The predicate checks the thrown value and up to 8 objects in its
causechain, cycle-safe:Response, or anErrorwith an integerstatusfrom 100 through 599, when the status is 408, 429, or 5xxErrorwhosecodeis a known transient network code:ConnectionRefusedorTimeout(Bun), or the errno-styleECONNREFUSED,ECONNRESET,ETIMEDOUT,ENOTFOUND,EAI_AGAIN(Bun and Node.js, including thecauseof undici'sfetch failed)TimeoutErrorDOMExceptionfrom APIs such asAbortSignal.timeout()TypeErrorwith an exact known failed-fetch message:fetch failedon Node.js and Deno 2.9+, one of the three browser strings, or theerror sending requestprefix from older Deno releasesAbortErrorstays false. Abort is caller intent, so retrying it is a bug.Design notes
500 <= status < 600instead ofisServerErrorStatus. That helper rejects unregistered codes such as Cloudflare's 520-526. A 522 test guards this.fetch failed, noterror sending request ..., since fix(ext/fetch): reject transport failures with Node's "fetch failed" shape deno#35618. The older prefix stays because pre-2.9 Deno remains in the CI matrix.fetch failedyet (alignment is in flight in fetch: reject network errors as TypeError('fetch failed' / 'terminated') with the system error as cause oven-sh/bun#35988 and fetch: reject network errors as TypeError('fetch failed') with cause, errno codes, and a caller stack oven-sh/bun#35998). Bun 1.4 throws TypeErrors identified bycode, with messages that cannot be exact-matched: the DNS failure embeds the hostname. Hence the code allowlist, verified against real Bun 1.4 fetch failures. Deterministic codes such asERR_INVALID_URLstay excluded, and a test guards non-string codes.Review notes
Fetch failed: Requests to port 6000 are blocked.http/test registered there.Responseon.response, including ky/got-style errors, are outside this API.test-bunfailure (isGlob works with the input that includes large number of open brackets) is unrelated: a Bun 1.4.0 regression innode:worker_threadsWorkerconstruction that also reproduces onmain.Testing
deno task okanddeno task test:nodepass, anddeno task test:bun(Bun 1.4.0) passes this module's tests. The new module has 19 tests with 100% line and branch coverage.