Skip to content

Commit 5e3fff8

Browse files
committed
Fix connection timeout leak
1 parent 5058a57 commit 5e3fff8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/connection.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function Connection(options = {}) {
137137
}
138138

139139
function connect() {
140-
connect_timeout && (connect_timer = setTimeout(connectTimedOut, connect_timeout * 1000))
140+
connect_timeout && (clearTimeout(connect_timer), connect_timer = setTimeout(connectTimedOut, connect_timeout * 1000))
141141
socket.connect()
142142
}
143143

@@ -176,7 +176,7 @@ function Connection(options = {}) {
176176
}
177177

178178
function onready(err) {
179-
connect_timer && (clearTimeout(connect_timer), connect_timer = null)
179+
clearTimeout(connect_timer)
180180
if (err) {
181181
if (backend.query) {
182182
err.stack += backend.query.origin.replace(/.*\n/, '\n')
@@ -226,7 +226,7 @@ function Connection(options = {}) {
226226
}
227227

228228
function close() {
229-
connect_timer && (clearTimeout(connect_timer), connect_timer = null)
229+
clearTimeout(connect_timer)
230230
error(errors.connection('CONNECTION_CLOSED', options))
231231
statements = {}
232232
messages = []

0 commit comments

Comments
 (0)