Repository navigation
fix(fetch): preserve falsy abort reasons - #6232
Merged
mcollina merged 1 commit intoNov 21, 2026
Merged
Conversation
Fetch.abort treated any falsy error as "not given" and replaced false, 0, and '' with a generic AbortError DOMException. Fall back only when the abort reason is undefined. Refs: nodejs#6231 Signed-off-by: rome-xi <2685138823@qq.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6232 +/- ##
=======================================
Coverage 91.71% 91.72%
=======================================
Files 113 113
Lines 44813 44813
=======================================
+ Hits 41102 41103 +1
+ Misses 3711 3710 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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 #6231.
When
fetchis aborted with a falsy reason (false,0, or''),Fetch.aborttreated that value as "not given" (if (!error)) and replaced it with a genericAbortErrorDOMException. The Fetch Standard abort steps use the supplied error, so the body (and the pending fetch) should reject with that reason.This changes the fallback to
error === undefinedonly.controller.abort()with no argument still rejects with anAbortError. Truthy custom reasons are unchanged.Tests
test/fetch/abort.jscovers abort while reading the response body (the issue repro) and while the fetch is still waiting for a response:false,0, and''reject with a value that isObject.is-equal tosignal.reasonErrorstill worksAbortErrorDOMExceptionThese five body-read cases fail on current
mainand pass after the change.node --test test/fetch/abort.js: 16 passing. A nearby abort slice (abort.js,abort2.js, and related issue tests): 47 passing, 6 skipped.