Update Fix

This commit is contained in:
2026-03-15 12:30:40 +01:00
parent 311ba5e7f3
commit 50be8e25f3
176 changed files with 4075 additions and 3013 deletions

View File

@@ -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) {