fix(fetch): preserve abort reasons in fetch adapter#10806
Merged
jasonsaayman merged 2 commits intoaxios:v1.xfrom Apr 27, 2026
Merged
fix(fetch): preserve abort reasons in fetch adapter#10806jasonsaayman merged 2 commits intoaxios:v1.xfrom
jasonsaayman merged 2 commits intoaxios:v1.xfrom
Conversation
Based on the work in axios#7191. Co-authored-by: Mostafa-Khairy0 <mostafakhairy0305@gmail.com> Co-authored-by: Jason Saayman <jasonsaayman@gmail.com>
8495afd to
9e4cbce
Compare
Member
|
5 tasks
This was referenced Apr 28, 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.
Summary
Fixes #7190.
This is a fallback PR based on the existing work in #7191, because pushing a follow-up commit to
Mostafa-Khairy0:fix-fetch-timeout-safariwas denied by GitHub. Credit goes to @Mostafa-Khairy0 for the original PR and to @jasonsaayman for narrowing the fix to axios' composed abort reason.What changed
composedSignal.reasonbefore reading the caught error. This avoids Safari DOMException-like getter failures.AxiosErrorwithETIMEDOUT.CanceledError/ERR_CANCELEDinstead of reclassifying it as timeout.ETIMEDOUT, matching the fetch adapter timeout path.Tests
npm run test:vitest:unit -- tests/unit/adapters/fetch.test.jsnpm run test:vitest:unit -- tests/unit/composeSignals.test.jsnpm run buildnpm run test:smoke:bunwas not run locally because Bun is not installed in this environment.Summary by cubic
Fixes Safari abort handling in the
fetchadapter by preserving the composed abort reason and correctly distinguishing timeouts (ETIMEDOUT) from user cancels (ERR_CANCELED). This prevents DOMException getter crashes and makes error behavior consistent across runtimes.Description
Summary of changes
composedSignal.reasonbefore inspecting the thrown error.AxiosErrorwith codeETIMEDOUT; user cancels throwCanceledErrorwithERR_CANCELED.causewhen propagating the composed abort reason, and keepconfig/requeston the error.ETIMEDOUTforfetchadapter timeouts.Reasoning
name/messagecan crash.Additional context
fetchadapter’s timeout path with existing timeout semantics inaxios.Docs
/docs/to clarify:fetchadapter timeout errors useETIMEDOUT.ERR_CANCELEDand are detectable viaaxios.isCancel(err)orCanceledError.Testing
tests/unit/adapters/fetch.test.js:AxiosErrorwithETIMEDOUT.CanceledError(ERR_CANCELED) even with Safari-like broken DOMException.ETIMEDOUT.tests/smoke/bun/tests/timeout.smoke.test.tsto expectETIMEDOUT.Semantic version impact
fetchadapter error normalization.fetchadapter is nowETIMEDOUT(wasECONNABORTEDin some cases). Consumers checking for timeout by code should handleETIMEDOUT.Written for commit 3ff04a2. Summary will update on new commits. Review in cubic