Skip to content

Commit

Permalink
Merge pull request #1660 from huycn/fix_warning_on_interaction_timeout
Browse files Browse the repository at this point in the history
Fix issue #1334: warning "packets out of order" when handling ER_CLIENT_INTERACTION_TIMEOUT
  • Loading branch information
sidorares committed Jan 30, 2023
2 parents 4ae073d + 389360e commit 7956989
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,19 +433,6 @@ class Connection extends EventEmitter {
this._paused_packets.push(packet);
return;
}
if (packet) {
if (this.sequenceId !== packet.sequenceId) {
const err = new Error(
`Warning: got packets out of order. Expected ${this.sequenceId} but received ${packet.sequenceId}`
);
err.expected = this.sequenceId;
err.received = packet.sequenceId;
this.emit('warn', err); // REVIEW
// eslint-disable-next-line no-console
console.error(err.message);
}
this._bumpSequenceId(packet.numPackets);
}
if (this.config.debug) {
if (packet) {
// eslint-disable-next-line no-console
Expand Down Expand Up @@ -484,6 +471,20 @@ class Connection extends EventEmitter {
this.close();
return;
}
if (packet) {
// Note: when server closes connection due to inactivity, Err packet ER_CLIENT_INTERACTION_TIMEOUT from MySQL 8.0.24, sequenceId will be 0
if (this.sequenceId !== packet.sequenceId) {
const err = new Error(
`Warning: got packets out of order. Expected ${this.sequenceId} but received ${packet.sequenceId}`
);
err.expected = this.sequenceId;
err.received = packet.sequenceId;
this.emit('warn', err); // REVIEW
// eslint-disable-next-line no-console
console.error(err.message);
}
this._bumpSequenceId(packet.numPackets);
}
const done = this._command.execute(packet, this);
if (done) {
this._command = this._commands.shift();
Expand Down

0 comments on commit 7956989

Please sign in to comment.