@compforge/harness-toolbox 0.3.8 → 0.3.9
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.
|
@@ -9,6 +9,9 @@ import {
|
|
|
9
9
|
queryMysqlViaPod,
|
|
10
10
|
queryMysqlViaPodBatch
|
|
11
11
|
} from "./chunk-m91t44jh.js";
|
|
12
|
+
import {
|
|
13
|
+
ToolboxError
|
|
14
|
+
} from "./chunk-zhkrydeg.js";
|
|
12
15
|
import {
|
|
13
16
|
ConcurrencyPool
|
|
14
17
|
} from "./chunk-v3hxvnrc.js";
|
|
@@ -18,6 +21,16 @@ import {
|
|
|
18
21
|
|
|
19
22
|
// src/mysql/client.ts
|
|
20
23
|
import { createConnection } from "mysql2/promise";
|
|
24
|
+
function mysqlOperationError(error, phase) {
|
|
25
|
+
if (!error || typeof error !== "object" || !("code" in error) || error.code !== "PROTOCOL_CONNECTION_LOST")
|
|
26
|
+
return error;
|
|
27
|
+
return new ToolboxError(`MySQL ${phase} failed: connection lost (PROTOCOL_CONNECTION_LOST)`, {
|
|
28
|
+
kind: "connection_lost",
|
|
29
|
+
code: error.code,
|
|
30
|
+
cause: error
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
21
34
|
class MysqlDatabase {
|
|
22
35
|
transports;
|
|
23
36
|
options;
|
|
@@ -56,6 +69,8 @@ class MysqlDatabase {
|
|
|
56
69
|
throw new Error("Bounded readonly MySQL queries require a native TCP transport");
|
|
57
70
|
try {
|
|
58
71
|
return await queryReadonlySession(session.connection, sql, values, limits, this.options.signal);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
throw mysqlOperationError(error, "query");
|
|
59
74
|
} finally {
|
|
60
75
|
destroyMysqlConnection(session.connection);
|
|
61
76
|
}
|
|
@@ -94,7 +109,7 @@ class MysqlDatabase {
|
|
|
94
109
|
this.#connections.delete(key);
|
|
95
110
|
if (session?.kind === "tcp")
|
|
96
111
|
destroyMysqlConnection(session.connection);
|
|
97
|
-
throw error;
|
|
112
|
+
throw session ? mysqlOperationError(error, "query") : error;
|
|
98
113
|
}
|
|
99
114
|
}
|
|
100
115
|
async#query(target, sql, values) {
|
|
@@ -130,9 +145,11 @@ class MysqlDatabase {
|
|
|
130
145
|
this.options.onRoute?.({ transport: endpoint.host === target.host && endpoint.port === target.port ? "direct" : transport.name, reason });
|
|
131
146
|
return { kind: "tcp", connection };
|
|
132
147
|
} catch (error) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
148
|
+
const failure = mysqlOperationError(error, "connect");
|
|
149
|
+
const connectionLost = failure instanceof ToolboxError && failure.kind === "connection_lost";
|
|
150
|
+
if (!isConnectionNetworkError(failure) && !connectionLost || i === this.transports.length - 1)
|
|
151
|
+
throw failure;
|
|
152
|
+
reason = String(failure.code);
|
|
136
153
|
}
|
|
137
154
|
}
|
|
138
155
|
throw new Error("MySQL DataSource has no transport");
|
package/dist/mysql/client.d.ts
CHANGED
|
@@ -8,7 +8,11 @@ export interface MysqlDatabaseOptions extends ClientLifecycle {
|
|
|
8
8
|
queryTimeoutMs: number;
|
|
9
9
|
}
|
|
10
10
|
type ConnectionFactory = (options: ConnectionOptions) => Promise<Connection>;
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* @spec SQL is executed once; only native connection establishment may advance to another transport.
|
|
13
|
+
* @why mysql2 reports a socket closed during handshake as PROTOCOL_CONNECTION_LOST, before any SQL is sent.
|
|
14
|
+
* @case id=mysql_handshake_closed,desc=`Peer closes during handshake`,expect=`Try the next transport`,forbid=`Replay an interrupted query`
|
|
15
|
+
*/
|
|
12
16
|
export declare class MysqlDatabase implements Database {
|
|
13
17
|
#private;
|
|
14
18
|
private readonly transports;
|
package/dist/mysql/client.js
CHANGED
|
@@ -2,10 +2,11 @@ import {
|
|
|
2
2
|
MysqlClient,
|
|
3
3
|
MysqlDatabase,
|
|
4
4
|
openMysql
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-ahc00qs5.js";
|
|
6
6
|
import"../chunk-age65q4n.js";
|
|
7
7
|
import"../chunk-136egyff.js";
|
|
8
8
|
import"../chunk-m91t44jh.js";
|
|
9
|
+
import"../chunk-zhkrydeg.js";
|
|
9
10
|
import"../chunk-v3hxvnrc.js";
|
|
10
11
|
import"../chunk-h8fwx0k7.js";
|
|
11
12
|
import"../chunk-wv4jwhvj.js";
|
package/dist/mysql/index.js
CHANGED
|
@@ -14,10 +14,11 @@ import {
|
|
|
14
14
|
MysqlClient,
|
|
15
15
|
MysqlDatabase,
|
|
16
16
|
openMysql
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-ahc00qs5.js";
|
|
18
18
|
import"../chunk-age65q4n.js";
|
|
19
19
|
import"../chunk-136egyff.js";
|
|
20
20
|
import"../chunk-m91t44jh.js";
|
|
21
|
+
import"../chunk-zhkrydeg.js";
|
|
21
22
|
import"../chunk-v3hxvnrc.js";
|
|
22
23
|
import"../chunk-h8fwx0k7.js";
|
|
23
24
|
import"../chunk-wv4jwhvj.js";
|