Update Fix
This commit is contained in:
42
node_modules/mysql2/lib/base/connection.js
generated
vendored
42
node_modules/mysql2/lib/base/connection.js
generated
vendored
@@ -21,7 +21,7 @@ const Timers = require('timers');
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const Readable = require('stream').Readable;
|
||||
const Queue = require('denque');
|
||||
const SqlString = require('sqlstring');
|
||||
const SqlString = require('sql-escaper');
|
||||
const { createLRU } = require('lru.min');
|
||||
const PacketParser = require('../packet_parser.js');
|
||||
const Packets = require('../packets/index.js');
|
||||
@@ -835,27 +835,31 @@ class BaseConnection extends EventEmitter {
|
||||
if (!cb) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._fatalError || this._protocolError) {
|
||||
return cb(this._fatalError || this._protocolError);
|
||||
}
|
||||
|
||||
if (this._handshakePacket) {
|
||||
return cb(null, this);
|
||||
}
|
||||
let connectCalled = 0;
|
||||
function callbackOnce(isErrorHandler) {
|
||||
return function (param) {
|
||||
if (!connectCalled) {
|
||||
if (isErrorHandler) {
|
||||
cb(param);
|
||||
} else {
|
||||
cb(null, param);
|
||||
}
|
||||
}
|
||||
connectCalled = 1;
|
||||
};
|
||||
}
|
||||
this.once('error', callbackOnce(true));
|
||||
this.once('connect', callbackOnce(false));
|
||||
|
||||
/* eslint-disable prefer-const */
|
||||
let onError, onConnect;
|
||||
|
||||
onError = (param) => {
|
||||
this.removeListener('connect', onConnect);
|
||||
cb(param);
|
||||
};
|
||||
|
||||
onConnect = (param) => {
|
||||
this.removeListener('error', onError);
|
||||
cb(null, param);
|
||||
};
|
||||
/* eslint-enable prefer-const */
|
||||
|
||||
this.once('error', onError);
|
||||
this.once('connect', onConnect);
|
||||
}
|
||||
|
||||
// ===================================
|
||||
@@ -922,6 +926,12 @@ class BaseConnection extends EventEmitter {
|
||||
return this.addCommand(new Commands.ServerHandshake(args));
|
||||
}
|
||||
|
||||
[Symbol.dispose]() {
|
||||
if (!this._closing) {
|
||||
this.end();
|
||||
}
|
||||
}
|
||||
|
||||
// ===============================================================
|
||||
end(callback) {
|
||||
if (this.config.isServer) {
|
||||
|
||||
Reference in New Issue
Block a user