Skip to content

Commit 7b6b7a1

Browse files
committed
Always call handleError asynchronously
This doesn’t match the original behaviour of the type errors, but it’s correct.
1 parent 6cba93d commit 7b6b7a1

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Diff for: lib/client.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,11 @@ Client.prototype._pulseQueryQueue = function () {
383383

384384
const queryError = this.activeQuery.submit(this.connection)
385385
if (queryError) {
386-
this.activeQuery.handleError(queryError, this.connection)
387-
this.readyForQuery = true
388-
this._pulseQueryQueue()
386+
process.nextTick(() => {
387+
this.activeQuery.handleError(queryError, this.connection)
388+
this.readyForQuery = true
389+
this._pulseQueryQueue()
390+
})
389391
}
390392
} else if (this.hasExecuted) {
391393
this.activeQuery = null
@@ -423,12 +425,16 @@ Client.prototype.query = function (config, values, callback) {
423425
}
424426

425427
if (!this._queryable) {
426-
query.handleError(new Error('Client has encountered a connection error and is not queryable'), this.connection)
428+
process.nextTick(() => {
429+
query.handleError(new Error('Client has encountered a connection error and is not queryable'), this.connection)
430+
})
427431
return
428432
}
429433

430434
if (this._ending) {
431-
query.handleError(new Error('Client was closed and is not queryable'), this.connection)
435+
process.nextTick(() => {
436+
query.handleError(new Error('Client was closed and is not queryable'), this.connection)
437+
})
432438
return
433439
}
434440

0 commit comments

Comments
 (0)