From f8b969e800ffe2ad2fc984e15458bbe238b81490 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Thu, 13 Mar 2025 13:13:30 +0100 Subject: [PATCH] deps: update undici to 6.21.2 Signed-off-by: Matteo Collina PR-URL: https://github.com/nodejs/node/pull/57442 Reviewed-By: Antoine du Hamel Reviewed-By: Rafael Gonzaga --- deps/undici/src/lib/dispatcher/pool.js | 14 ++++++++++++++ deps/undici/src/lib/llhttp/wasm_build_env.txt | 8 ++++---- deps/undici/src/package.json | 2 +- deps/undici/src/types/interceptors.d.ts | 1 + deps/undici/undici.js | 8 ++++++++ src/undici_version.h | 2 +- 6 files changed, 29 insertions(+), 6 deletions(-) diff --git a/deps/undici/src/lib/dispatcher/pool.js b/deps/undici/src/lib/dispatcher/pool.js index 2d84cd96488..0b8a2da6da4 100644 --- a/deps/undici/src/lib/dispatcher/pool.js +++ b/deps/undici/src/lib/dispatcher/pool.js @@ -73,6 +73,20 @@ class Pool extends PoolBase { ? { ...options.interceptors } : undefined this[kFactory] = factory + + this.on('connectionError', (origin, targets, error) => { + // If a connection error occurs, we remove the client from the pool, + // and emit a connectionError event. They will not be re-used. + // Fixes https://github.com/nodejs/undici/issues/3895 + for (const target of targets) { + // Do not use kRemoveClient here, as it will close the client, + // but the client cannot be closed in this state. + const idx = this[kClients].indexOf(target) + if (idx !== -1) { + this[kClients].splice(idx, 1) + } + } + }) } [kGetDispatcher] () { diff --git a/deps/undici/src/lib/llhttp/wasm_build_env.txt b/deps/undici/src/lib/llhttp/wasm_build_env.txt index c92b0aa26e0..5ce088f4338 100644 --- a/deps/undici/src/lib/llhttp/wasm_build_env.txt +++ b/deps/undici/src/lib/llhttp/wasm_build_env.txt @@ -1,15 +1,15 @@ -> undici@6.21.1 prebuild:wasm +> undici@6.21.2 prebuild:wasm > node build/wasm.js --prebuild -> docker build --platform=linux/aarch64 -t llhttp_wasm_builder -f /Users/matteo/repos/node-private/deps/undici/src/build/Dockerfile /Users/matteo/repos/node-private/deps/undici/src +> docker build --platform=linux/aarch64 -t llhttp_wasm_builder -f /Users/matteo/repos/node/deps/undici/src/build/Dockerfile /Users/matteo/repos/node/deps/undici/src -> undici@6.21.1 build:wasm +> undici@6.21.2 build:wasm > node build/wasm.js --docker -> docker run --rm -t --platform=linux/aarch64 --mount type=bind,source=/Users/matteo/repos/node-private/deps/undici/src/lib/llhttp,target=/home/node/undici/lib/llhttp llhttp_wasm_builder node build/wasm.js +> docker run --rm -t --platform=linux/aarch64 --mount type=bind,source=/Users/matteo/repos/node/deps/undici/src/lib/llhttp,target=/home/node/undici/lib/llhttp llhttp_wasm_builder node build/wasm.js alpine-baselayout-3.4.3-r2 diff --git a/deps/undici/src/package.json b/deps/undici/src/package.json index a465327b1bc..d7fab14768a 100644 --- a/deps/undici/src/package.json +++ b/deps/undici/src/package.json @@ -1,6 +1,6 @@ { "name": "undici", - "version": "6.21.1", + "version": "6.21.2", "description": "An HTTP/1.1 client, written from scratch for Node.js", "homepage": "https://undici.nodejs.org", "bugs": { diff --git a/deps/undici/src/types/interceptors.d.ts b/deps/undici/src/types/interceptors.d.ts index 65e9397554e..9f6af128d5e 100644 --- a/deps/undici/src/types/interceptors.d.ts +++ b/deps/undici/src/types/interceptors.d.ts @@ -28,4 +28,5 @@ declare namespace Interceptors { export function retry(opts?: RetryInterceptorOpts): Dispatcher.DispatcherComposeInterceptor export function redirect(opts?: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor export function responseError(opts?: ResponseErrorInterceptorOpts): Dispatcher.DispatcherComposeInterceptor + export function dns (opts?: DNSInterceptorOpts): Dispatcher.DispatcherComposeInterceptor } diff --git a/deps/undici/undici.js b/deps/undici/undici.js index 42387a0ea7e..d65ffba0ff6 100644 --- a/deps/undici/undici.js +++ b/deps/undici/undici.js @@ -8123,6 +8123,14 @@ var require_pool = __commonJS({ this[kOptions] = { ...util.deepClone(options), connect, allowH2 }; this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0; this[kFactory] = factory; + this.on("connectionError", (origin2, targets, error) => { + for (const target of targets) { + const idx = this[kClients].indexOf(target); + if (idx !== -1) { + this[kClients].splice(idx, 1); + } + } + }); } [kGetDispatcher]() { for (const client of this[kClients]) { diff --git a/src/undici_version.h b/src/undici_version.h index 9cca99eae90..e47161c2a85 100644 --- a/src/undici_version.h +++ b/src/undici_version.h @@ -2,5 +2,5 @@ // Refer to tools/dep_updaters/update-undici.sh #ifndef SRC_UNDICI_VERSION_H_ #define SRC_UNDICI_VERSION_H_ -#define UNDICI_VERSION "6.21.1" +#define UNDICI_VERSION "6.21.2" #endif // SRC_UNDICI_VERSION_H_