This commit is contained in:
2026-03-15 12:22:42 +01:00
parent cd99275933
commit 311ba5e7f3
558 changed files with 55182 additions and 22981 deletions

View File

@@ -345,7 +345,9 @@ class BaseConnection extends EventEmitter {
});
const rejectUnauthorized = this.config.ssl.rejectUnauthorized;
const verifyIdentity = this.config.ssl.verifyIdentity;
const servername = this.config.host;
const servername = Net.isIP(this.config.host)
? undefined
: this.config.host;
let secureEstablished = false;
this.stream.removeAllListeners('data');
@@ -410,6 +412,37 @@ class BaseConnection extends EventEmitter {
this.emit('error', err);
}
get state() {
// Error state has highest priority
if (this._fatalError || this._protocolError) {
return 'error';
}
// Closing state has second priority
if (this._closing || (this.stream && this.stream.destroyed)) {
return 'disconnected';
}
// Authenticated state has third priority
if (this.authorized) {
return 'authenticated';
}
// Connected state: handshake completed but not yet authorized
// This matches the original mysql driver's 'connected' state
if (this._handshakePacket) {
return 'connected';
}
// Protocol handshake state: connection established, handshake in progress
if (this.stream && !this.stream.destroyed) {
return 'protocol_handshake';
}
// Default: not connected
return 'disconnected';
}
get fatalError() {
return this._fatalError;
}