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.
In enviroments that implement it.
When an
AbortSignal#reasonhas a value, i.e. in nodejs >= v17.2.0, it is added on the returnedAbortError.AbortError#reasonwould beundefinedotherwise.Contrary to the specification, when
AbortController#abortis called, with or without a reason,fetchdoes not throw theAbortSignal#reason. This is to allow more fine grained error handling. Had thereasonwas thrown, the general information that an abort happened is lost and it becomes sole responsibility of the reason provider.Purpose
Allow detecting the reason fetch was aborted.
Changes
AbortErrorto have fieldreason. It's constructor takes this additional argument.AbortSignal#reasonis given when constructingAbortErrorinstance. Could possibly beundefinedin environments/libraries/polyfills that do not support it.Additional information
The actual value (even existence) of
AbortSignal#reasonis external to this library. We make no assumptions about it. We simply forward it.This goes against #1519. There is no inherent reason to follow the specifications to the dot.
node-fetchis for node, specifically, not the web. TBD.