* fix: turn AxiosError into a native error (#5394)
Being an object returned by the 'Error' constructor turns something into a 'native error'.
* fix: simplify code in AxiosError
* fix: simplify code in AxiosError
* refactor: implement AxiosError as a class
* refactor: implement CanceledError as a class
This turns CanceledError into a native error.
* refactor: simplify AxiosError.toJSON
* fix: improve error code handling in `AxiosError.from`
If no error code is provided, use the code from the underlying error.
* fix: set error status in `AxiosError.constructor`
If a response is passed to the constructor, set the response status as a property.
* fix: remove unnecessary async
---------
Co-authored-by: Jay <jasonsaayman@gmail.com>
* feat(adapter): surface low‑level network error details; attach original 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
* fix(adapter): use fs instead of fs/promises for sync file read in tests to fix GitHub Actions
* Added AxiosHeaders class;
* Fixed README.md href;
* Fixed a potential bug with headers normalization;
* Fixed a potential bug with headers normalization;
Refactored accessor building routine;
Refactored default transforms;
Removed `normalizeHeaderName` helper;
* Added `Content-Length` accessor;
Added missed `has` accessor to TS types;
* Added `AxiosTransformStream` class;
Added progress capturing ability for node.js environment;
Added `maxRate` option to limit the data rate in node.js environment;
Refactored event handled by `onUploadProgress` && `onDownloadProgress` listeners in browser environment;
Added progress & data rate tests for the http adapter;
Added response stream aborting test;
Added a manual progress capture test for the browser;
Updated TS types;
Added TS tests;
Refactored request abort logic for the http adapter;
Added ability to abort the response stream;
* Remove `stream/promises` & `timers/promises` modules usage in tests;
* Use `abortcontroller-polyfill`;
* Fixed AxiosTransformStream dead-lock in legacy node versions;
Fixed CancelError emitting in streams;
* Reworked AxiosTransformStream internal logic to optimize memory consumption;
Added throwing an error if the request stream was silently destroying (without error) Refers to #3966;
* Treat the destruction of the request stream as a cancellation of the request;
Fixed tests;
* Emit `progress` event in the next tick;
* Initial refactoring;
* Refactored Mocha tests to use ESM;
* Refactored Karma tests to use rollup preprocessor & ESM;
Replaced grunt with gulp;
Improved dev scripts;
Added Babel for rollup build;
* Added default commonjs package export for Node build;
Added automatic contributors list generator for package.json;
Co-authored-by: Jay <jasonsaayman@gmail.com>
* Added data URL support for node.js;
Added missed data URL protocol for the browser environment;
Optimized JSON parsing in the default response transformer;
Refactored project structure;
Added `cause` prop for AxiosError instance that refers to the original error if it was wrapped with `AxiosError.from` method;
Added fromDataURI helper;
Added test for handling data:url as an `arraybuffer|text|stream`;
* Added throwing of 405 HTTP error if the method is not GET;
Related to discussions here https://github.com/axios/axios/issues/2387
Attempt to capture the stack trace at the time the error is created in
order to maintain context about where the error originates from.
Co-authored-by: Jay <jasonsaayman@gmail.com>
Refactored `Cancel` to a constructor, a subclass of the `AxiosError`;
Expose CanceledError class;
Refactored axios error codes;
Added `toFlatObject` util;