From 0bf4608d606f3c2c01ce9400c32fc9165cfc70b2 Mon Sep 17 00:00:00 2001 From: Akash Dhar Dubey Date: Tue, 9 Dec 2025 14:27:25 +0530 Subject: [PATCH 01/14] docs: add typescript example for custom instance (#7288) * docs: add abort controller example * docs: add typescript example for custom instance * Update server.js * Delete examples/abort-controller/server.js * Delete examples/abort-controller/index.html --------- Co-authored-by: Jay --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index a0c09ec5a3..85a7b00e17 100644 --- a/README.md +++ b/README.md @@ -1778,6 +1778,25 @@ If use ESM, your settings should be fine. If you compile TypeScript to CJS and you can’t use `"moduleResolution": "node 16"`, you have to enable `esModuleInterop`. If you use TypeScript to type check CJS JavaScript code, your only option is to use `"moduleResolution": "node16"`. + +You can also create a custom instance with typed interceptors: + +```typescript +import axios, { AxiosInstance, InternalAxiosRequestConfig } from 'axios'; + +const apiClient: AxiosInstance = axios.create({ + baseURL: 'https://api.example.com', + timeout: 10000, +}); + +apiClient.interceptors.request.use( + (config: InternalAxiosRequestConfig) => { + // Add auth token + return config; + } +); +``` + ## Online one-click setup You can use Gitpod, an online IDE(which is free for Open Source) for contributing or running the examples online. From d7e60653460480ffacecf85383012ca1baa6263e Mon Sep 17 00:00:00 2001 From: Subhan Kumar Rai Date: Fri, 19 Dec 2025 05:52:38 +0530 Subject: [PATCH 02/14] fix(http2): Use port 443 for HTTPS connections by default. (#7256) Co-authored-by: Dmitriy Mozgovoy --- lib/adapters/http.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/adapters/http.js b/lib/adapters/http.js index dfa6386d32..6a8a05dd2a 100755 --- a/lib/adapters/http.js +++ b/lib/adapters/http.js @@ -268,7 +268,8 @@ const buildAddressEntry = (address, family) => resolveFamily(utils.isObject(addr const http2Transport = { request(options, cb) { - const authority = options.protocol + '//' + options.hostname + ':' + (options.port || 80); + const authority = options.protocol + '//' + options.hostname + ':' + (options.port ||(options.protocol === 'https:' ? 443 : 80)); + const {http2Options, headers} = options; From 21df8edc8a9031ea29b675ccdb4cc9ee89bf7a5b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 19 Dec 2025 08:54:05 +0200 Subject: [PATCH 03/14] chore(sponsor): update sponsor block (#7308) Co-authored-by: DigitalBrainJS <12586868+DigitalBrainJS@users.noreply.github.com> --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 85a7b00e17..733985c0da 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ Route4Me

Best Route Planning And Route Optimization Software

Explore | Free Trial | Contact

Buzzoid - Buy Instagram Followers

At Buzzoid, you can buy Instagram followers quickly, safely, and easily with just a few clicks. Rate...

buzzoid.com

Poprey - Buy Instagram Likes

Buy Instagram Likes

poprey.com

- Requestly

A lightweight open-source API Development, Testing & Mocking platform

requestly.com

- 💜 Become a sponsor + Букмекер

Ставки на спорт, БК в Україні

betking.com.ua

+ Requestly

A lightweight open-source API Development, Testing & Mocking platform

requestly.com

💜 Become a sponsor From 9af869126b679c4be0e00119343feb2462694579 Mon Sep 17 00:00:00 2001 From: Lubos Date: Tue, 23 Dec 2025 16:14:39 +0800 Subject: [PATCH 04/14] Add "API clients" section to Ecosystem (#7312) Moved the existing API client generators to their own section and added Hey API --- ECOSYSTEM.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ECOSYSTEM.md b/ECOSYSTEM.md index b0257fe330..35244575ee 100644 --- a/ECOSYSTEM.md +++ b/ECOSYSTEM.md @@ -16,10 +16,14 @@ This is a list of axios related libraries and resources. If you have a suggestio * [axios-api-versioning](https://weffe.github.io/axios-api-versioning) - Add easy to manage api versioning to axios * [axios-data-unpacker](https://github.com/anubhavsrivastava/axios-data-unpacker) - Axios interceptor that unpacks HTTP responses so that you can focus on actual server data. * [r2curl](https://github.com/uyu423/r2curl) - Extracts the cURL command string from the Axios object. (AxiosResponse, AxiosRequestConfig) -* [swagger-taxos-codegen](https://github.com/michalzaq12/swagger-taxos-codegen) - Axios based Swagger Codegen (tailored for typescript) * [axios-endpoints](https://github.com/renancaraujo/axios-endpoints) - Axios endpoints help you to create a more concise endpoint mapping with axios. * [axios-multi-api](https://github.com/MattCCC/axios-multi-api) - Easy API handling whenever there are many endpoints to add. It helps to make Axios requests in an easy and declarative manner. * [axios-url-template](https://github.com/rafw87/axios-url-template) - Axios interceptor adding support for URL templates. + +### API clients + +* [@hey-api/openapi-ts](https://heyapi.dev/openapi-ts/clients/axios) - The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more. +* [swagger-taxos-codegen](https://github.com/michalzaq12/swagger-taxos-codegen) - Axios based Swagger Codegen (tailored for typescript) * [zodios](https://www.zodios.org) - Typesafe API client based on axios ### Logging and debugging From 25446920e3188bebdf94b428c30a9f7f9ddf4bde Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Dec 2025 08:07:11 +0200 Subject: [PATCH 05/14] chore(deps): bump peter-evans/create-pull-request (#7303) Bumps the github-actions group with 1 update: [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request). Updates `peter-evans/create-pull-request` from 7 to 8 - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](https://github.com/peter-evans/create-pull-request/compare/v7...v8) --- updated-dependencies: - dependency-name: peter-evans/create-pull-request dependency-version: '8' dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/pr.yml | 2 +- .github/workflows/sponsors.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index f221b0e01a..28d8d273ac 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -58,7 +58,7 @@ jobs: with: run: node ./bin/pr.js - name: Create pull request - uses: peter-evans/create-pull-request@v7 + uses: peter-evans/create-pull-request@v8 id: cpr with: branch: release diff --git a/.github/workflows/sponsors.yml b/.github/workflows/sponsors.yml index 5df13dcbaa..54cd872bd5 100644 --- a/.github/workflows/sponsors.yml +++ b/.github/workflows/sponsors.yml @@ -44,7 +44,7 @@ jobs: echo "$CONTENT" - name: Create pull request if: ${{ steps.sponsors.outputs.changed == 'true'}} - uses: peter-evans/create-pull-request@v7 + uses: peter-evans/create-pull-request@v8 id: cpr with: branch: sponsors From 53aa420bb262b78891275adf3150fce046028d2e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Dec 2025 08:07:33 +0200 Subject: [PATCH 06/14] chore(deps): bump the production_dependencies group across 1 directory with 2 updates (#7231) Bumps the production_dependencies group with 2 updates in the / directory: [follow-redirects](https://github.com/follow-redirects/follow-redirects) and [form-data](https://github.com/form-data/form-data). Updates `follow-redirects` from 1.15.6 to 1.15.11 - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.6...v1.15.11) Updates `form-data` from 4.0.4 to 4.0.5 - [Release notes](https://github.com/form-data/form-data/releases) - [Changelog](https://github.com/form-data/form-data/blob/master/CHANGELOG.md) - [Commits](https://github.com/form-data/form-data/compare/v4.0.4...v4.0.5) --- updated-dependencies: - dependency-name: follow-redirects dependency-version: 1.15.11 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: production_dependencies - dependency-name: form-data dependency-version: 4.0.5 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: production_dependencies ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jay --- package-lock.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index d5604b1149..a3086512ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11782,9 +11782,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.6", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", - "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "version": "1.15.11", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz", + "integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==", "funding": [ { "type": "individual", @@ -11861,9 +11861,9 @@ } }, "node_modules/form-data": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", - "integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz", + "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -36255,9 +36255,9 @@ } }, "follow-redirects": { - "version": "1.15.6", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", - "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==" + "version": "1.15.11", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz", + "integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==" }, "for-in": { "version": "1.0.2", @@ -36299,9 +36299,9 @@ "dev": true }, "form-data": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", - "integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz", + "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==", "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", From bf3f63237c194e26f23aba066d655c989a93ad5e Mon Sep 17 00:00:00 2001 From: Joseph Frazier <1212jtraceur@gmail.com> Date: Tue, 30 Dec 2025 01:10:46 -0500 Subject: [PATCH 07/14] docs: fix typo in multipart/form-data README section (#7311) Co-authored-by: Jay --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 733985c0da..ffbb9fc40e 100644 --- a/README.md +++ b/README.md @@ -1098,7 +1098,7 @@ If your backend body-parser (like `body-parser` of `express.js`) supports nested ### FormData -To send the data as a `multipart/formdata` you need to pass a formData instance as a payload. +To send the data as a `multipart/form-data` you need to pass a formData instance as a payload. Setting the `Content-Type` header is not required as Axios guesses it based on the payload type. ```js From 38be3b2e18fd35bc89d46a6cd3fe2379191fd5f6 Mon Sep 17 00:00:00 2001 From: Akash Dhar Dubey Date: Tue, 30 Dec 2025 16:39:44 +0530 Subject: [PATCH 08/14] docs: add abort controller example (#7287) Co-authored-by: Jay --- examples/abort-controller/index.html | 132 +++++++++++++++++++++++++++ examples/abort-controller/server.js | 16 ++++ 2 files changed, 148 insertions(+) create mode 100644 examples/abort-controller/index.html create mode 100644 examples/abort-controller/server.js diff --git a/examples/abort-controller/index.html b/examples/abort-controller/index.html new file mode 100644 index 0000000000..bd3747ae65 --- /dev/null +++ b/examples/abort-controller/index.html @@ -0,0 +1,132 @@ + + + + axios - abort controller example + + + + +

axios.AbortController

+ +
+
+

1. Single Request Cancellation

+

Click "Start Request" to begin a 3-second request. Click "Cancel Request" to abort it.

+ + +
+
+
+ +
+ +
+
+

2. Search-as-you-type (Race Condition Handling)

+

Type quickly. Previous pending requests will be cancelled automatically.

+
+ +
+
+
    +
    +
    + + + + + diff --git a/examples/abort-controller/server.js b/examples/abort-controller/server.js new file mode 100644 index 0000000000..8e27326576 --- /dev/null +++ b/examples/abort-controller/server.js @@ -0,0 +1,16 @@ +import url from 'url'; + +export default function (req, res) { + const parsedUrl = url.parse(req.url, true); + const delay = parsedUrl.query.delay || 3000; + + setTimeout(() => { + res.writeHead(200, { + 'Content-Type': 'text/json' + }); + res.write(JSON.stringify({ + message: 'Response completed successfully after ' + delay + 'ms' + })); + res.end(); + }, delay); +}; From 3141c319c285f4bcb99143e6871fdba5cc89bcf6 Mon Sep 17 00:00:00 2001 From: Ved Vadnere Date: Tue, 30 Dec 2025 16:41:30 +0530 Subject: [PATCH 09/14] chore: remove unnecessary eslint-disable directive (#7283) Co-authored-by: Jay --- bin/actions/notify_published.js | 6 +++--- lib/core/mergeConfig.js | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/bin/actions/notify_published.js b/bin/actions/notify_published.js index ddacdec31d..22a50d9432 100644 --- a/bin/actions/notify_published.js +++ b/bin/actions/notify_published.js @@ -5,11 +5,11 @@ import fs from 'fs/promises'; const argv = minimist(process.argv.slice(2)); console.log(argv); -let {tag} = argv; +let { tag } = argv; -(async() => { +(async () => { if (!tag || tag === true) { - const {version} = JSON.parse((await fs.readFile('./package.json')).toString()); + const { version } = JSON.parse((await fs.readFile('./package.json')).toString()); tag = 'v' + version; } else if (typeof tag !== 'string') { diff --git a/lib/core/mergeConfig.js b/lib/core/mergeConfig.js index b1b50f0fc9..b7a43d5207 100644 --- a/lib/core/mergeConfig.js +++ b/lib/core/mergeConfig.js @@ -21,7 +21,7 @@ export default function mergeConfig(config1, config2) { function getMergedValue(target, source, prop, caseless) { if (utils.isPlainObject(target) && utils.isPlainObject(source)) { - return utils.merge.call({caseless}, target, source); + return utils.merge.call({ caseless }, target, source); } else if (utils.isPlainObject(source)) { return utils.merge({}, source); } else if (utils.isArray(source)) { @@ -30,7 +30,6 @@ export default function mergeConfig(config1, config2) { return source; } - // eslint-disable-next-line consistent-return function mergeDeepProperties(a, b, prop, caseless) { if (!utils.isUndefined(b)) { return getMergedValue(a, b, prop, caseless); @@ -96,7 +95,7 @@ export default function mergeConfig(config1, config2) { headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true) }; - utils.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) { + utils.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) { const merge = mergeMap[prop] || mergeDeepProperties; const configValue = merge(config1[prop], config2[prop], prop); (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue); From d6bbb3db86f3157e406620da8e68cc24cb8b4be9 Mon Sep 17 00:00:00 2001 From: rohit miryala <39668736+rohitmiryala@users.noreply.github.com> Date: Tue, 30 Dec 2025 16:44:19 +0530 Subject: [PATCH 10/14] docs: add async/await timeout handling example (#7250) Co-authored-by: Jay --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index ffbb9fc40e..035fdc9a11 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ - [Interceptors](#interceptors) - [Multiple Interceptors](#multiple-interceptors) - [Handling Errors](#handling-errors) + - [Handling Timeouts](#handling-timeouts) - [Cancellation](#cancellation) - [AbortController](#abortcontroller) - [CancelToken 👎](#canceltoken-deprecated) @@ -921,6 +922,27 @@ axios.get('/user/12345') }); ``` +## Handling Timeouts + +```js +async function fetchWithTimeout() { + try { + const response = await axios.get('https://example.com/data', { + timeout: 5000 // 5 seconds + }); + + console.log('Response:', response.data); + + } catch (error) { + if (axios.isAxiosError(error) && error.code === 'ECONNABORTED') { + console.error('❌ Request timed out!'); + } else { + console.error('❌ Error:', error.message); + } + } +} +``` + ## Cancellation ### AbortController From 46db3316ac1579633d82f468181c51186ab3af50 Mon Sep 17 00:00:00 2001 From: SANDESH LENDVE <123884782+mrsandy1965@users.noreply.github.com> Date: Tue, 30 Dec 2025 16:46:52 +0530 Subject: [PATCH 11/14] doc: update deprecated var usage in documentation examples (#7246) * test(http): fix HTTPS protocol test by using local HTTPS server instead of external request * docs: update var usage in documentation examples * docs: updated var to const --------- Co-authored-by: Jay --- README.md | 2 +- lib/helpers/spread.js | 2 +- lib/utils.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 035fdc9a11..dab106f135 100644 --- a/README.md +++ b/README.md @@ -1104,7 +1104,7 @@ The server will handle it as: If your backend body-parser (like `body-parser` of `express.js`) supports nested objects decoding, you will get the same object on the server-side automatically ```js - var app = express(); + const app = express(); app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies diff --git a/lib/helpers/spread.js b/lib/helpers/spread.js index 13479cb25c..2e72fc88f2 100644 --- a/lib/helpers/spread.js +++ b/lib/helpers/spread.js @@ -7,7 +7,7 @@ * * ```js * function f(x, y, z) {} - * var args = [1, 2, 3]; + * const args = [1, 2, 3]; * f.apply(null, args); * ``` * diff --git a/lib/utils.js b/lib/utils.js index ed081611d1..68bab356c4 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -333,7 +333,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob * Example: * * ```js - * var result = merge({foo: 123}, {foo: 456}); + * const result = merge({foo: 123}, {foo: 456}); * console.log(result.foo); // outputs 456 * ``` * From f8694341deaabd2e81059543fe03f9c791656903 Mon Sep 17 00:00:00 2001 From: techcodie Date: Tue, 30 Dec 2025 17:00:43 +0530 Subject: [PATCH 12/14] docs: refresh CDN URLs and example JSON headers (#7236) Co-authored-by: Jay --- README.md | 4 ++-- examples/get/server.js | 2 +- examples/post/server.js | 2 +- examples/postMultipartFormData/server.js | 2 +- lib/helpers/composeSignals.js | 2 +- test/unit/helpers/composeSignals.js | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index dab106f135..a915d51fb1 100644 --- a/README.md +++ b/README.md @@ -189,13 +189,13 @@ const axios = require('axios/dist/browser/axios.cjs'); // browser commonJS bundl Using jsDelivr CDN (ES5 UMD browser module): ```html - + ``` Using unpkg CDN: ```html - + ``` ## Example diff --git a/examples/get/server.js b/examples/get/server.js index 8a3622f5c7..7312f42b8d 100644 --- a/examples/get/server.js +++ b/examples/get/server.js @@ -27,7 +27,7 @@ const people = [ export default function (req, res) { res.writeHead(200, { - 'Content-Type': 'text/json' + 'Content-Type': 'application/json' }); res.write(JSON.stringify(people)); res.end(); diff --git a/examples/post/server.js b/examples/post/server.js index 1cb9c45fa6..68756d1b8d 100644 --- a/examples/post/server.js +++ b/examples/post/server.js @@ -8,7 +8,7 @@ export default function (req, res) { req.on('end', function () { console.log('POST data received'); res.writeHead(200, { - 'Content-Type': 'text/json' + 'Content-Type': 'application/json' }); res.write(JSON.stringify(data)); res.end(); diff --git a/examples/postMultipartFormData/server.js b/examples/postMultipartFormData/server.js index 9db463ea2c..eb95af6a34 100644 --- a/examples/postMultipartFormData/server.js +++ b/examples/postMultipartFormData/server.js @@ -6,7 +6,7 @@ export default function (req, res) { req.on('end', function () { console.log('POST received'); res.writeHead(200, { - 'Content-Type': 'text/json' + 'Content-Type': 'application/json' }); res.end(); }); diff --git a/lib/helpers/composeSignals.js b/lib/helpers/composeSignals.js index 84087c8067..cf27ddf5e3 100644 --- a/lib/helpers/composeSignals.js +++ b/lib/helpers/composeSignals.js @@ -21,7 +21,7 @@ const composeSignals = (signals, timeout) => { let timer = timeout && setTimeout(() => { timer = null; - onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT)) + onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT)) }, timeout) const unsubscribe = () => { diff --git a/test/unit/helpers/composeSignals.js b/test/unit/helpers/composeSignals.js index 961921e4ab..89cfa11abb 100644 --- a/test/unit/helpers/composeSignals.js +++ b/test/unit/helpers/composeSignals.js @@ -32,7 +32,7 @@ describe('helpers::composeSignals', () => { signal.addEventListener('abort', resolve); }); - assert.match(String(signal.reason), /timeout 100 of ms exceeded/); + assert.match(String(signal.reason), /timeout of 100ms exceeded/); }); it('should return undefined if signals and timeout are not provided', async () => { From 8d1271b49fc226ed7defd07cd577bd69a55bb13a Mon Sep 17 00:00:00 2001 From: Tibor Pilz Date: Tue, 30 Dec 2025 12:58:26 +0100 Subject: [PATCH 13/14] fix(types): add handlers to AxiosInterceptorManager interface (#5551) * fix(types): add handlers to AxiosInterceptorManager interface * fix: runwhen should be optional Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: make handlers optional * chore: optional handlers --------- Co-authored-by: Tibor Pilz Co-authored-by: Jay Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- index.d.cts | 22 ++++++++++++++++++++-- index.d.ts | 22 ++++++++++++++++++++-- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/index.d.cts b/index.d.cts index e3a06a3789..4be32f9cb3 100644 --- a/index.d.cts +++ b/index.d.cts @@ -515,14 +515,32 @@ declare namespace axios { runWhen?: (config: InternalAxiosRequestConfig) => boolean; } - type AxiosRequestInterceptorUse = (onFulfilled?: ((value: T) => T | Promise) | null, onRejected?: ((error: any) => any) | null, options?: AxiosInterceptorOptions) => number; + type AxiosInterceptorFulfilled = (value: T) => T | Promise; + type AxiosInterceptorRejected = (error: any) => any; - type AxiosResponseInterceptorUse = (onFulfilled?: ((value: T) => T | Promise) | null, onRejected?: ((error: any) => any) | null) => number; + type AxiosRequestInterceptorUse = ( + onFulfilled?: AxiosInterceptorFulfilled | null, + onRejected?: AxiosInterceptorRejected | null, + options?: AxiosInterceptorOptions + ) => number; + + type AxiosResponseInterceptorUse = ( + onFulfilled?: AxiosInterceptorFulfilled | null, + onRejected?: AxiosInterceptorRejected | null + ) => number; + + interface AxiosInterceptorHandler { + fulfilled: AxiosInterceptorFulfilled; + rejected?: AxiosInterceptorRejected; + synchronous: boolean; + runWhen?: (config: AxiosRequestConfig) => boolean; + } interface AxiosInterceptorManager { use: V extends AxiosResponse ? AxiosResponseInterceptorUse : AxiosRequestInterceptorUse; eject(id: number): void; clear(): void; + handlers?: Array>; } interface AxiosInstance extends Axios { diff --git a/index.d.ts b/index.d.ts index ff29215f5c..c562d9c08e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -494,14 +494,32 @@ export interface AxiosInterceptorOptions { runWhen?: (config: InternalAxiosRequestConfig) => boolean; } -type AxiosRequestInterceptorUse = (onFulfilled?: ((value: T) => T | Promise) | null, onRejected?: ((error: any) => any) | null, options?: AxiosInterceptorOptions) => number; +type AxiosInterceptorFulfilled = (value: T) => T | Promise; +type AxiosInterceptorRejected = (error: any) => any; -type AxiosResponseInterceptorUse = (onFulfilled?: ((value: T) => T | Promise) | null, onRejected?: ((error: any) => any) | null) => number; +type AxiosRequestInterceptorUse = ( + onFulfilled?: AxiosInterceptorFulfilled | null, + onRejected?: AxiosInterceptorRejected | null, + options?: AxiosInterceptorOptions +) => number; + +type AxiosResponseInterceptorUse = ( + onFulfilled?: AxiosInterceptorFulfilled | null, + onRejected?: AxiosInterceptorRejected | null +) => number; + +interface AxiosInterceptorHandler { + fulfilled: AxiosInterceptorFulfilled; + rejected?: AxiosInterceptorRejected; + synchronous: boolean; + runWhen: (config: AxiosRequestConfig) => boolean | null; +} export interface AxiosInterceptorManager { use: V extends AxiosResponse ? AxiosResponseInterceptorUse : AxiosRequestInterceptorUse; eject(id: number): void; clear(): void; + handlers?: Array>; } export class Axios { From 7373fbff24cd92ce650d99ff6f7fe08c2e2a0a04 Mon Sep 17 00:00:00 2001 From: Adam Hines Date: Tue, 30 Dec 2025 05:10:04 -0700 Subject: [PATCH 14/14] fix: main field in package.json should correspond to cjs artifacts (#5756) When https://github.com/axios/axios/pull/4787 was implemented, the project was switched to `"type": "module"` and "./index.js" became an esm file instead of commonjs, however, the "main" entry in package.json still points to "index.js". As a result, consumers using this field may get unexpected behavior since the main field is supposed to be commonjs if the entry is provided. Many consumers won't run into this as a practical problem (for example when just doing `const axios = require('axios').default` from inside of a cjs file in node) because the "exports" map takes precedence over the main/module fields, but tools that don't parse the object map when resolving still run into problems here. The fix for this is to just point the "main" entry-point to the commonjs artifacts located at "./dist/node/index.cjs". I also added a module entrypoint to improve compatability for the cases where the export map is not used (webpack 4 for example) since that would likely be reading the cjs "main" entrypoint now that main has switched back to cjs. Co-authored-by: Jay --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index f0973efed4..eb58f1a251 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,8 @@ "name": "axios", "version": "1.13.2", "description": "Promise based HTTP client for the browser and node.js", - "main": "index.js", + "main": "./dist/node/axios.cjs", + "module": "./index.js", "exports": { ".": { "types": {