diff options
Diffstat (limited to 'node_modules/undici/lib/pool.js')
| -rw-r--r-- | node_modules/undici/lib/pool.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/node_modules/undici/lib/pool.js b/node_modules/undici/lib/pool.js index e3cd339..86b29d4 100644 --- a/node_modules/undici/lib/pool.js +++ b/node_modules/undici/lib/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] () { |
