Skip to content

Commit

Permalink
Merge pull request #216 from BobdenOs/master
Browse files Browse the repository at this point in the history
Fix discarded enqueued queries
  • Loading branch information
IanMcCurdy committed Aug 29, 2023
2 parents 3f5b524 + 2662a29 commit cccd888
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/protocol/Connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ Connection.prototype._addListeners = function _addListeners(socket) {
function onend() {
var err = new Error('Connection closed by server');
err.code = 'EHDBCLOSE';
self._clearQueue(err);
onerror(err);
}
socket.on('end', onend);
Expand All @@ -276,8 +277,12 @@ Connection.prototype._addListeners = function _addListeners(socket) {
Connection.prototype._cleanup = function _cleanup() {
this._socket = undefined;
this._state = undefined;
this._clearQueue()
};

Connection.prototype._clearQueue = function _clearQueue(err) {
if (this._queue) {
this._queue.abort();
this._queue.abort(err);
this._queue = undefined;
}
};
Expand Down
3 changes: 2 additions & 1 deletion lib/util/Queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ Queue.prototype.pause = function pause() {
return this;
};

Queue.prototype.abort = function abort() {
Queue.prototype.abort = function abort(err) {
this.queue.forEach(t => t.receive(err))
this.queue = [];
this.busy = false;
this.running = false;
Expand Down

0 comments on commit cccd888

Please sign in to comment.