Skip to content

Commit ed88cf6

Browse files
committed
fix(client): properly clean up connection on errors
1 parent 3f8ba76 commit ed88cf6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/gaussdb-node/lib/client.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,17 @@ class Client extends EventEmitter {
345345
return
346346
}
347347
this._connectionError = true
348+
this._connecting = false
348349
clearTimeout(this.connectionTimeoutHandle)
350+
351+
if (this.connection && this.connection.stream) {
352+
this.connection.stream.destroy()
353+
}
354+
349355
if (this._connectionCallback) {
350-
return this._connectionCallback(err)
356+
const callback = this._connectionCallback
357+
this._connectionCallback = null
358+
return callback(err)
351359
}
352360
this.emit('error', err)
353361
}

0 commit comments

Comments
 (0)