mysql2 3.15.3 → 3.16.0
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.
package/lib/base/connection.js
CHANGED
|
@@ -412,6 +412,37 @@ class BaseConnection extends EventEmitter {
|
|
|
412
412
|
this.emit('error', err);
|
|
413
413
|
}
|
|
414
414
|
|
|
415
|
+
get state() {
|
|
416
|
+
// Error state has highest priority
|
|
417
|
+
if (this._fatalError || this._protocolError) {
|
|
418
|
+
return 'error';
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// Closing state has second priority
|
|
422
|
+
if (this._closing || (this.stream && this.stream.destroyed)) {
|
|
423
|
+
return 'disconnected';
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// Authenticated state has third priority
|
|
427
|
+
if (this.authorized) {
|
|
428
|
+
return 'authenticated';
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// Connected state: handshake completed but not yet authorized
|
|
432
|
+
// This matches the original mysql driver's 'connected' state
|
|
433
|
+
if (this._handshakePacket) {
|
|
434
|
+
return 'connected';
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// Protocol handshake state: connection established, handshake in progress
|
|
438
|
+
if (this.stream && !this.stream.destroyed) {
|
|
439
|
+
return 'protocol_handshake';
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// Default: not connected
|
|
443
|
+
return 'disconnected';
|
|
444
|
+
}
|
|
445
|
+
|
|
415
446
|
get fatalError() {
|
|
416
447
|
return this._fatalError;
|
|
417
448
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mysql2",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.16.0",
|
|
4
4
|
"description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "typings/mysql/index",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@eslint/eslintrc": "^3.3.0",
|
|
61
61
|
"@eslint/js": "^9.21.0",
|
|
62
62
|
"@eslint/markdown": "^7.0.0",
|
|
63
|
-
"@types/node": "^
|
|
63
|
+
"@types/node": "^25.0.2",
|
|
64
64
|
"@typescript-eslint/eslint-plugin": "^8.26.0",
|
|
65
65
|
"@typescript-eslint/parser": "^8.26.0",
|
|
66
66
|
"assert-diff": "^3.0.2",
|
|
@@ -339,6 +339,13 @@ export interface ConnectionOptions {
|
|
|
339
339
|
gracefulEnd?: boolean;
|
|
340
340
|
}
|
|
341
341
|
|
|
342
|
+
export type ConnectionState =
|
|
343
|
+
| 'disconnected'
|
|
344
|
+
| 'protocol_handshake'
|
|
345
|
+
| 'connected'
|
|
346
|
+
| 'authenticated'
|
|
347
|
+
| 'error';
|
|
348
|
+
|
|
342
349
|
declare class Connection extends QueryableBase(ExecutableBase(EventEmitter)) {
|
|
343
350
|
config: ConnectionOptions;
|
|
344
351
|
|
|
@@ -346,6 +353,8 @@ declare class Connection extends QueryableBase(ExecutableBase(EventEmitter)) {
|
|
|
346
353
|
|
|
347
354
|
authorized: boolean;
|
|
348
355
|
|
|
356
|
+
readonly state: ConnectionState;
|
|
357
|
+
|
|
349
358
|
static createQuery<
|
|
350
359
|
T extends
|
|
351
360
|
| RowDataPacket[][]
|