mysql2 3.1.0 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -86,7 +86,6 @@ module.exports = (pluginOptions = {}) => ({ connection }) => {
86
86
  `Invalid AuthMoreData packet received by ${PLUGIN_NAME} plugin in STATE_TOKEN_SENT state.`
87
87
  );
88
88
  case STATE_WAIT_SERVER_KEY:
89
- console.log('Server pub key:', data);
90
89
  if (pluginOptions.onServerPublicKey) {
91
90
  pluginOptions.onServerPublicKey(data);
92
91
  }
@@ -44,8 +44,8 @@ class ChangeUser extends Command {
44
44
  this.currentConfig.database = this.database;
45
45
  this.currentConfig.charsetNumber = this.charsetNumber;
46
46
  connection.clientEncoding = CharsetToEncoding[this.charsetNumber];
47
- // reset prepared statements cache as all statements become invalid after changeUser
48
- connection._statements.reset();
47
+ // clear prepared statements cache as all statements become invalid after changeUser
48
+ connection._statements.clear();
49
49
  connection.writePacket(newPacket.toPacket());
50
50
  // check if the server supports multi-factor authentication
51
51
  const multiFactorAuthentication = connection.serverCapabilityFlags & ClientConstants.MULTI_FACTOR_AUTHENTICATION;
package/lib/connection.js CHANGED
@@ -433,19 +433,6 @@ class Connection extends EventEmitter {
433
433
  this._paused_packets.push(packet);
434
434
  return;
435
435
  }
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
- }
449
436
  if (this.config.debug) {
450
437
  if (packet) {
451
438
  // eslint-disable-next-line no-console
@@ -484,6 +471,20 @@ class Connection extends EventEmitter {
484
471
  this.close();
485
472
  return;
486
473
  }
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
+ }
487
488
  const done = this._command.execute(packet, this);
488
489
  if (done) {
489
490
  this._command = this._commands.shift();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysql2",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -80,7 +80,6 @@
80
80
  "eslint-plugin-async-await": "0.0.0",
81
81
  "eslint-plugin-markdown": "^3.0.0",
82
82
  "husky": "^8.0.2",
83
- "is-async-supported": "^1.2.0",
84
83
  "lint-staged": "^13.0.3",
85
84
  "mocha": "^10.0.0",
86
85
  "portfinder": "^1.0.28",