Skip to content

Commit 73f6018

Browse files
fix: properly release the client when calling io.close()
1 parent f87dc5f commit 73f6018

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,11 @@ export function createAdapter(
103103
let isConnectionInProgress = false;
104104
let client: PoolClient | undefined;
105105
let cleanupTimer: NodeJS.Timeout;
106+
let reconnectTimer: NodeJS.Timeout;
106107

107108
const scheduleReconnection = () => {
108109
const reconnectionDelay = Math.floor(2000 * (0.5 + Math.random()));
109-
setTimeout(initClient, reconnectionDelay);
110+
reconnectTimer = setTimeout(initClient, reconnectionDelay);
110111
};
111112

112113
const initClient = async () => {
@@ -184,9 +185,8 @@ export function createAdapter(
184185
client.release();
185186
client = undefined;
186187
}
187-
if (cleanupTimer) {
188-
clearTimeout(cleanupTimer);
189-
}
188+
clearTimeout(reconnectTimer);
189+
clearTimeout(cleanupTimer);
190190
}
191191

192192
defaultClose.call(adapter);

0 commit comments

Comments
 (0)