From 1876f2000a81eb8510e11c93e9f80700014bcf67 Mon Sep 17 00:00:00 2001 From: francesco Date: Mon, 10 Mar 2025 18:16:57 +0100 Subject: [PATCH] Add "unref" to timers (#3396) * chore: add unref to timer see https://nodejs.org/api/timers.html#timeoutunref * chore: add unref to timer see https://nodejs.org/api/timers.html#timeoutunref * fix: lint * fix: lint * fix: lint * fix: lint --- packages/pg-pool/index.js | 4 ++++ packages/pg/lib/client.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/packages/pg-pool/index.js b/packages/pg-pool/index.js index e7d2d883..0a88d829 100644 --- a/packages/pg-pool/index.js +++ b/packages/pg-pool/index.js @@ -205,6 +205,10 @@ class Pool extends EventEmitter { response.callback(new Error('timeout exceeded when trying to connect')) }, this.options.connectionTimeoutMillis) + if (tid.unref) { + tid.unref() + } + this._pendingQueue.push(pendingItem) return result } diff --git a/packages/pg/lib/client.js b/packages/pg/lib/client.js index 527f62e4..1304c951 100644 --- a/packages/pg/lib/client.js +++ b/packages/pg/lib/client.js @@ -104,6 +104,10 @@ class Client extends EventEmitter { con._ending = true con.stream.destroy(new Error('timeout expired')) }, this._connectionTimeoutMillis) + + if (this.connectionTimeoutHandle.unref) { + this.connectionTimeoutHandle.unref() + } } if (this.host && this.host.indexOf('/') === 0) {