From d0ef299f3b521ff8c1bd18179dda4c81c06b0396 Mon Sep 17 00:00:00 2001 From: "Node.js GitHub Bot" Date: Fri, 4 Dec 2026 13:04:57 +0000 Subject: [PATCH] deps: update undici to 8.14.1 --- deps/undici/src/README.md | 3 +- deps/undici/src/docs/docs/api/Client.md | 8 +- deps/undici/src/docs/docs/api/Dispatcher.md | 6 + .../src/docs/docs/api/EnvHttpProxyAgent.md | 9 + deps/undici/src/docs/docs/api/Fetch.md | 117 +++++++++++ deps/undici/src/docs/docs/api/H2CClient.md | 7 +- deps/undici/src/docs/docs/api/Interceptors.md | 36 ++-- deps/undici/src/lib/api/api-request.js | 4 +- deps/undici/src/lib/api/api-stream.js | 11 +- deps/undici/src/lib/api/readable.js | 39 ++-- .../src/lib/cache/memory-cache-store.js | 7 +- .../src/lib/cache/sqlite-cache-store.js | 6 +- deps/undici/src/lib/core/symbols.js | 1 + deps/undici/src/lib/core/util.js | 5 +- deps/undici/src/lib/dispatcher/agent.js | 4 +- deps/undici/src/lib/dispatcher/client-h1.js | 5 +- deps/undici/src/lib/dispatcher/client-h2.js | 76 ++++++- .../src/lib/dispatcher/dispatcher-base.js | 11 +- .../lib/dispatcher/env-http-proxy-agent.js | 24 ++- deps/undici/src/lib/dispatcher/pool-base.js | 13 +- deps/undici/src/lib/dispatcher/proxy-agent.js | 5 +- deps/undici/src/lib/dispatcher/retry-agent.js | 5 +- .../src/lib/dispatcher/socks5-proxy-agent.js | 4 +- deps/undici/src/lib/handler/cache-handler.js | 63 +++++- .../src/lib/handler/redirect-handler.js | 44 +++- deps/undici/src/lib/handler/retry-handler.js | 13 +- deps/undici/src/lib/interceptor/cache.js | 160 +++++++------- deps/undici/src/lib/interceptor/dump.js | 4 +- deps/undici/src/lib/interceptor/redirect.js | 3 + deps/undici/src/lib/interceptor/retry.js | 19 +- deps/undici/src/lib/util/cache.js | 198 +++++++++++++++++- .../lib/web/eventsource/eventsource-stream.js | 2 +- deps/undici/src/package-lock.json | 48 ++--- deps/undici/src/package.json | 2 +- deps/undici/src/types/client.d.ts | 4 +- deps/undici/src/types/dispatcher.d.ts | 2 + deps/undici/src/types/h2c-client.d.ts | 4 +- deps/undici/undici.js | 145 ++++++++++--- src/undici_version.h | 2 +- 39 files changed, 883 insertions(+), 236 deletions(-) diff --git a/deps/undici/src/README.md b/deps/undici/src/README.md index e5af5f7ec8b9..8d0be890e215 100644 --- a/deps/undici/src/README.md +++ b/deps/undici/src/README.md @@ -795,7 +795,6 @@ and `undici.Agent`) which will enable the family autoselection algorithm when es * [__Carlos Fuentes__](https://github.com/metcoder95), * [__Ethan Arrowood__](https://github.com/Ethan-Arrowood), * [__Matteo Collina__](https://github.com/mcollina), -* [__Matthew Aitken__](https://github.com/KhafraDev), * [__Mert Can Altin__](https://github.com/mertcanaltin), * [__Robert Nagy__](https://github.com/ronag), * [__Trivikram Kamat__](https://github.com/trivikr), @@ -804,13 +803,13 @@ and `undici.Agent`) which will enable the family autoselection algorithm when es ## Past Collaborators * [__Szymon Marczak__](https://github.com/szmarczak), * [__Tomas Della Vedova__](https://github.com/delvedor), +* [__Matthew Aitken__](https://github.com/KhafraDev), ### Releasers * [__Ethan Arrowood__](https://github.com/ethan-arrowood), * [__Matteo Collina__](https://github.com/mcollina), * [__Robert Nagy__](https://github.com/ronag), -* [__Matthew Aitken__](https://github.com/KhafraDev), ## Long Term Support diff --git a/deps/undici/src/docs/docs/api/Client.md b/deps/undici/src/docs/docs/api/Client.md index 36f6a4f24656..0b0ce3c59fdd 100644 --- a/deps/undici/src/docs/docs/api/Client.md +++ b/deps/undici/src/docs/docs/api/Client.md @@ -73,8 +73,10 @@ added: v1.0.0 * `maxResponseSize` {number|null} The maximum length of a response body, in bytes. Set to `-1` to disable it. **Default:** `-1`. * `maxRequestsPerClient` {number|null} The maximum number of requests to send - over a single connection before the socket is reset. Use `0` to disable this - limit. **Default:** `null`. + over a single connection. For HTTP/2, once this limit is reached, the client + lets existing streams finish and closes the session before sending queued + requests on a new connection. Use `0` to disable this limit. **Default:** + `null`. * `localAddress` {string|null} The local IP address the socket should connect from. **Default:** `null`. * `pipelining` {number|null} The number of concurrent requests sent over the @@ -113,7 +115,7 @@ added: v1.0.0 higher priority through ALPN negotiation. **Default:** `true`. * `useH2c` {boolean} _Deprecated: use h2Options.useH2c instead_ Enforces h2c (HTTP/2 cleartext) for non-HTTPS connections. **Default:** `false`. - * `maxConcurrentStreams` {number} _Deprecated: use h2Options.useH2c instead_ The maximum number of concurrent HTTP/2 + * `maxConcurrentStreams` {number} _Deprecated: use h2Options.maxConcurrentStreams instead_ The maximum number of concurrent HTTP/2 streams for a single session. Once h2 is negotiated this — not `pipelining`, which is HTTP/1.1 only — is the ceiling used to dispatch in-flight requests. The server's `SETTINGS_MAX_CONCURRENT_STREAMS` can lower this limit, but diff --git a/deps/undici/src/docs/docs/api/Dispatcher.md b/deps/undici/src/docs/docs/api/Dispatcher.md index b278f328ce1b..c8689d4f36d0 100644 --- a/deps/undici/src/docs/docs/api/Dispatcher.md +++ b/deps/undici/src/docs/docs/api/Dispatcher.md @@ -243,6 +243,12 @@ added: v4.0.0 * `expectContinue` {boolean} For HTTP/2, appends the `expect: 100-continue` header and halts the request body until a `100 Continue` is received from the remote server. **Default:** `false`. + * `servername` {string} The TLS server name (SNI) to use for this request on + `https:` origins. **Default:** the hostname of the `host` header, if any + (IP addresses are not used). A client reconnects when the server name of the + next queued request differs from the one of its current connection, and + waits for any running requests to finish first. Set this to share one + connection across requests with different `host` headers. * `handler` {Object} A set of callbacks invoked over the request lifecycle. * `onRequestStart` {Function} Invoked before the request is dispatched on the socket. May be invoked multiple times when the request is retried. diff --git a/deps/undici/src/docs/docs/api/EnvHttpProxyAgent.md b/deps/undici/src/docs/docs/api/EnvHttpProxyAgent.md index f14b8760964e..e3e251f3db22 100644 --- a/deps/undici/src/docs/docs/api/EnvHttpProxyAgent.md +++ b/deps/undici/src/docs/docs/api/EnvHttpProxyAgent.md @@ -66,6 +66,15 @@ Creates a new `EnvHttpProxyAgent`. Any options other than `httpProxy`, not affect any request until it is registered as a dispatcher, either globally with `setGlobalDispatcher()` or per-request through the `dispatcher` option. +The TLS options for the connection to the target server, given as `requestTls` +or as a `connect` object, apply on every route: direct (no proxy configured), +hosts matching `noProxy`, and proxied through an HTTP, HTTPS, or SOCKS5 proxy. +When both are set they are merged key by key, and keys set in `connect` take +precedence over `requestTls` on every route. `proxyTls` applies only to the connection to the +proxy server, and the target TLS options are never applied to it. When `connect` +is a function it is used as-is on direct routes, where `requestTls` is then not +applied, and it is not used on proxied routes. + ```mjs import { EnvHttpProxyAgent } from 'undici' diff --git a/deps/undici/src/docs/docs/api/Fetch.md b/deps/undici/src/docs/docs/api/Fetch.md index 86bc8d70c20a..6ceb64e26082 100644 --- a/deps/undici/src/docs/docs/api/Fetch.md +++ b/deps/undici/src/docs/docs/api/Fetch.md @@ -97,6 +97,119 @@ const response = await fetch('https://example.com', { }) ``` +### Composition and interceptors + +undici's [`Dispatcher.compose()`][] composes a chain of interceptors over the +dispatcher's `dispatch()` method, returning a new dispatcher. Passing that +composed dispatcher to `fetch()` via `init.dispatcher` is the supported way +to add retry, cache, custom redirect handling, header dumping, or any +user-defined behaviour around a `fetch()` call — without changing the +WHATWG `fetch()` surface itself. + +The following recipes cover the most common questions about `fetch()` +behaviour. Each one builds a dispatcher once and reuses it for every call. + +#### Automatic retry + +Retry transient network errors and 5xx responses, without manual loops: + +```mjs +import { fetch, Agent, interceptors } from 'undici' + +const dispatcher = new Agent().compose(interceptors.retry({ + maxRetries: 3, + minTimeout: 500, + maxTimeout: 5_000, + timeoutFactor: 2, + // Methods allowed to retry; the default list excludes POST and PATCH + // to avoid replaying non-idempotent side effects. + methods: ['GET', 'HEAD', 'OPTIONS', 'PUT', 'DELETE', 'TRACE', 'QUERY'], + statusCodes: [500, 502, 503, 504, 429], + errorCodes: ['ECONNRESET', 'ECONNREFUSED', 'ENOTFOUND', 'ENETDOWN', + 'ENETUNREACH', 'EHOSTDOWN', 'EHOSTUNREACH', 'EPIPE', 'UND_ERR_SOCKET'] +})) + +const response = await fetch('https://example.com/api', { dispatcher }) +``` + +See [`RetryHandler`][] for the full option reference. + +#### HTTP caching + +Serve responses from an in-memory or SQLite cache store, honouring +`Cache-Control` and `Vary`: + +```mjs +import { fetch, Agent, interceptors, cacheStores } from 'undici' + +const dispatcher = new Agent().compose(interceptors.cache({ + store: new cacheStores.MemoryCacheStore(), + methods: ['GET', 'HEAD'] +})) + +const response = await fetch('https://example.com/api', { dispatcher }) +``` + +See [CacheStore][] for store options. + +#### Custom redirect handling + +Follow redirects a limited number of times, with optional header-stripping on +cross-origin hops: + +```mjs +import { fetch, Agent, interceptors } from 'undici' + +const dispatcher = new Agent().compose(interceptors.redirect({ + maxRedirections: 5, + stripHeadersOnCrossOriginRedirect: ['authorization', 'cookie'] +})) + +const response = await fetch('https://example.com/old-path', { dispatcher }) +``` + +#### Response error enrichment + +Surface a `ResponseError` (with status + headers + body preview) instead of a +raw `Response` when the server returns 4xx/5xx: + +```mjs +import { fetch, Agent, interceptors } from 'undici' + +const dispatcher = new Agent().compose(interceptors.responseError({ + // Max response body bytes buffered into the thrown ResponseError. + maxSize: 128 * 1024 +})) + +try { + await fetch('https://example.com/missing', { dispatcher }) +} catch (err) { + // err is a ResponseError with err.statusCode, err.headers, err.body +} +``` + +#### Chaining multiple interceptors + +`compose()` accepts an array; the order matters — the LAST interceptor in the +array runs FIRST on the outbound request: + +```mjs +import { fetch, Agent, interceptors } from 'undici' + +const dispatcher = new Agent().compose([ + interceptors.retry({ maxRetries: 2 }), + interceptors.redirect({ maxRedirections: 5 }), + interceptors.cache({ store: new cacheStores.MemoryCacheStore() }) +]) + +// On the way out: cache → redirect → retry → network. +// On the way back: network → retry → redirect → cache. +const response = await fetch('https://example.com/api', { dispatcher }) +``` + +See [`Dispatcher.compose()`][] for the full composition semantics, and +[Interceptors][] for the complete list of built-in interceptors. + ## Class: `FormData`