Change8

v1.16.0

Breaking Changes
📦 axiosView on GitHub →
3 breaking3 features🐛 19 fixes1 deprecations🔧 19 symbols

Summary

Version 1.16.0 introduces support for the QUERY HTTP method and the ECONNREFUSED error constant, alongside significant bug fixes across HTTP, fetch, and XHR adapters concerning redirects, headers, and timeouts. Several observable behaviors have changed, particularly around content length enforcement and protocol parsing strictness.

⚠️ Breaking Changes

  • Fetch adapter now enforces `maxBodyLength` and `maxContentLength`. Previously, these limits were silently ignored on the fetch adapter, removing a safety net for DoS protection or large uploads.
  • `parseProtocol` now strictly requires a colon in the protocol separator. Strings that loosely parsed as protocols before may no longer match.
  • Deprecated `unescape()` usage was replaced with modern UTF-8 encoding. Consumers depending on legacy `unescape()` quirks may see different output bytes due to spec-correct non-ASCII URL handling.

Migration Steps

  1. Review code that relies on loose protocol parsing in `parseProtocol`; ensure protocols now explicitly contain a colon separator.
  2. If relying on the previous behavior of the fetch adapter ignoring `maxBodyLength`/`maxContentLength`, update code to respect these limits or remove them if they are no longer desired safety measures.

✨ New Features

  • Added support for the QUERY HTTP method across adapters and type definitions.
  • Exposed `ECONNREFUSED` as a constant on `AxiosError` for easier matching of connection-refused failures.
  • Exported the internal `encode` helper from `buildURL` to allow userland param serializers to reuse internal encoding logic.

🐛 Bug Fixes

  • HTTP Adapter: Cleared stale headers when a redirect targets a no-proxy host.
  • HTTP Adapter: Fixed the redirect listener chain so listeners no longer stack across hops.
  • HTTP Adapter: Restored the missing `requestDetails` argument on `beforeRedirect`.
  • HTTP Adapter: Preserved user-supplied `Host` headers when forwarding through a proxy.
  • HTTP Adapter: Properly URL-decoded basic auth credentials.
  • HTTP Adapter: Preserved the partial response object on `AxiosError` when a stream is aborted after headers arrive.
  • HTTP Adapter: Honoured the `timeout` option during the connect phase when redirects are disabled.
  • HTTP Adapter: Resolved an unsettled-promise hang when an aborted request was combined with compression and `maxRedirects: 0`.
  • Fetch Adapter: Enforced `maxBodyLength` / `maxContentLength`.
  • Fetch Adapter: Set the `User-Agent` header to match the HTTP adapter.
  • Fetch Adapter: Preserved the original abort reason instead of replacing it with a generic error.
  • Fetch Adapter: Deferred global access so importing the module no longer throws a `TypeError` in restricted environments.
  • XHR Adapter: Unsubscribed the `cancelToken` and `AbortSignal` listeners on the error, timeout, and abort code paths to prevent leaked subscriptions.
  • Error Handling: Attached the parsed response to `AxiosError` when `parse` fails inside `dispatchRequest`.
  • Error Handling: Prevented `settle` from emitting `undefined` error codes.
  • Types & Exports: Aligned the CommonJS `CancelToken` typings with the ESM build.
  • Types & Exports: Fixed a compiler error caused by `RawAxiosHeaders`.
  • Types & Exports: Re-exported `create` from the package index.
  • UTF-8 Encoding: Replaced the deprecated `unescape()` call with a modern UTF-8 encoding implementation.

Affected Symbols

⚡ Deprecations

  • The `unescape()` function usage has been deprecated and replaced with modern UTF-8 encoding.