Skip to content

Commit 7956989

Browse files
authored
Merge pull request #1660 from huycn/fix_warning_on_interaction_timeout
Fix issue #1334: warning "packets out of order" when handling ER_CLIENT_INTERACTION_TIMEOUT
2 parents 4ae073d + 389360e commit 7956989

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

lib/connection.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -433,19 +433,6 @@ class Connection extends EventEmitter {
433433
this._paused_packets.push(packet);
434434
return;
435435
}
436-
if (packet) {
437-
if (this.sequenceId !== packet.sequenceId) {
438-
const err = new Error(
439-
`Warning: got packets out of order. Expected ${this.sequenceId} but received ${packet.sequenceId}`
440-
);
441-
err.expected = this.sequenceId;
442-
err.received = packet.sequenceId;
443-
this.emit('warn', err); // REVIEW
444-
// eslint-disable-next-line no-console
445-
console.error(err.message);
446-
}
447-
this._bumpSequenceId(packet.numPackets);
448-
}
449436
if (this.config.debug) {
450437
if (packet) {
451438
// eslint-disable-next-line no-console
@@ -484,6 +471,20 @@ class Connection extends EventEmitter {
484471
this.close();
485472
return;
486473
}
474+
if (packet) {
475+
// Note: when server closes connection due to inactivity, Err packet ER_CLIENT_INTERACTION_TIMEOUT from MySQL 8.0.24, sequenceId will be 0
476+
if (this.sequenceId !== packet.sequenceId) {
477+
const err = new Error(
478+
`Warning: got packets out of order. Expected ${this.sequenceId} but received ${packet.sequenceId}`
479+
);
480+
err.expected = this.sequenceId;
481+
err.received = packet.sequenceId;
482+
this.emit('warn', err); // REVIEW
483+
// eslint-disable-next-line no-console
484+
console.error(err.message);
485+
}
486+
this._bumpSequenceId(packet.numPackets);
487+
}
487488
const done = this._command.execute(packet, this);
488489
if (done) {
489490
this._command = this._commands.shift();

0 commit comments

Comments
 (0)