feat(adapter): surface low‑level network error details; attach origin…#6982
Merged
jasonsaayman merged 3 commits intoaxios:v1.xfrom Jul 30, 2025
Merged
feat(adapter): surface low‑level network error details; attach origin…#6982jasonsaayman merged 3 commits intoaxios:v1.xfrom
jasonsaayman merged 3 commits intoaxios:v1.xfrom
Conversation
…al error via `cause` Node http adapter: - Promote low-level `err.code` to `AxiosError.code`, prefixing message (e.g. `ECONNREFUSED – …`) - Keep original error on standard `Error.cause` XHR adapter: - Preserve browser `ProgressEvent` on `error.event` - Use event message when available Tests: - Add Node ESM tests under `test/unit/adapters` to assert `code` and `cause` behavior Types: - Ensure `AxiosError.cause?: unknown` and `event?: ProgressEvent` are present
jasonsaayman
approved these changes
Jul 30, 2025
Member
jasonsaayman
left a comment
There was a problem hiding this comment.
Very nicely done @mkhani01! 🔥
|
Had the same problem, thanks @mkhani01 🙏🏻 |
Merged
Contributor
This was referenced Oct 27, 2025
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.
✨ Title
feat(adapter): surface low-level network error details; attach original error via
cause🧾 What?
This pull request enhances how network errors are surfaced in both Node HTTP and XHR adapters for Axios:
err.codeintoAxiosError.code, prefixes the error message (e.g.ECONNREFUSED – …), and preserves the original error inError.cause.ProgressEventaserror.eventand uses its message when available.test/unit/adaptersto verifycodeandcausebehavior.AxiosError.cause?: unknownandevent?: ProgressEventare present in type definitions.❓ Why?
Provides greater error transparency for developers. By preserving both
codeand original error context (cause), we enable easier debugging in both server and browser environments. This change improves observability and developer experience.🔧 How?
codeis now promoted toAxiosError.code, and the message is prefixed accordingly. The original exception is attached via the standardError.cause.ProgressEventfrom the browsererror.eventis preserved and used when its message is present.code,cause, andevent.cause?: unknownandevent?: ProgressEvent.✅ Testing
test/unit/adaptersspecific tocode,cause, andeventsemantics.📎 Related tickets / Issues
6965
🧵 Any breaking changes?
No breaking API changes. This preserves backwards-compatible optional behaviors; adapters will still function normally if no
err.codeor event is present.Summary
This PR significantly improves debugging clarity by surface-level error code preservation, original error chaining via
cause, and richer type safety—while ensuring both browser and Node adapters behave consistently.