diff --git a/lib/agent.js b/lib/agent.js index 0b18f2a91bd..4ac34d26335 100644 --- a/lib/agent.js +++ b/lib/agent.js @@ -124,6 +124,7 @@ class Agent extends DispatcherBase { const client = ref.deref() /* istanbul ignore else: gc is undeterministic */ if (client) { + this[kFinalizer].unregister(client) closePromises.push(client.close()) } } @@ -137,6 +138,7 @@ class Agent extends DispatcherBase { const client = ref.deref() /* istanbul ignore else: gc is undeterministic */ if (client) { + this[kFinalizer].unregister(client) destroyPromises.push(client.destroy(err)) } } diff --git a/lib/core/connect.js b/lib/core/connect.js index 877956f7bee..2d2521dcfbd 100644 --- a/lib/core/connect.js +++ b/lib/core/connect.js @@ -15,7 +15,7 @@ let tls // include tls conditionally since it is not always available let SessionCache // FIXME: remove workaround when the Node bug is fixed // https://github.com/nodejs/node/issues/49344#issuecomment-1741776308 -if (global.FinalizationRegistry && !process.env.NODE_V8_COVERAGE) { +if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { SessionCache = class WeakSessionCache { constructor (maxCachedSessions) { this._maxCachedSessions = maxCachedSessions diff --git a/test/balanced-pool.js b/test/balanced-pool.js index 7806652d95b..0e7c1bb169a 100644 --- a/test/balanced-pool.js +++ b/test/balanced-pool.js @@ -437,7 +437,7 @@ const cases = [ expectedRatios: [0.34, 0.34, 0.32], // Skip because the behavior of Node.js has changed - skip: nodeMajor >= 19 + skip: nodeMajor >= 18 }, // 8