@testsprite/testsprite-cli 0.13.0 → 0.14.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/README.md +51 -48
- package/dist/commands/doctor.js +12 -11
- package/dist/commands/project-env.d.ts +11 -1
- package/dist/commands/project-env.js +399 -61
- package/dist/commands/project-sign-in.d.ts +60 -0
- package/dist/commands/project-sign-in.js +289 -0
- package/dist/commands/project.d.ts +9 -0
- package/dist/commands/project.js +68 -28
- package/dist/commands/schedule.d.ts +12 -0
- package/dist/commands/schedule.js +175 -5
- package/dist/commands/test.d.ts +53 -20
- package/dist/commands/test.js +1356 -342
- package/dist/commands/testlist.d.ts +10 -5
- package/dist/commands/testlist.js +170 -30
- package/dist/commands/tunnel.js +11 -5
- package/dist/index.js +12 -37
- package/dist/lib/client-factory.d.ts +12 -1
- package/dist/lib/client-factory.js +14 -4
- package/dist/lib/dry-run/samples.js +53 -0
- package/dist/lib/environment-tunnel.d.ts +109 -0
- package/dist/lib/environment-tunnel.js +465 -0
- package/dist/lib/errors.js +12 -1
- package/dist/lib/gh-output.js +3 -0
- package/dist/lib/http.d.ts +2 -0
- package/dist/lib/junit-report.d.ts +11 -7
- package/dist/lib/junit-report.js +13 -7
- package/dist/lib/local-target.d.ts +13 -3
- package/dist/lib/local-target.js +47 -12
- package/dist/lib/output.js +15 -1
- package/dist/lib/plan-poll.js +3 -4
- package/dist/lib/redact.d.ts +38 -0
- package/dist/lib/redact.js +140 -0
- package/dist/lib/render-error.d.ts +19 -5
- package/dist/lib/render-error.js +31 -0
- package/dist/lib/runs.types.d.ts +9 -1
- package/dist/lib/target-url.js +5 -5
- package/dist/lib/telemetry.d.ts +6 -7
- package/dist/lib/telemetry.js +11 -4
- package/dist/lib/testlist.types.d.ts +1 -0
- package/dist/lib/ticker.d.ts +9 -0
- package/dist/lib/ticker.js +18 -0
- package/dist/lib/tunnel-session.d.ts +3 -4
- package/dist/lib/tunnel-session.js +3 -4
- package/dist/lib/v3-advisory.js +0 -1
- package/dist/vendor/tunnel-client/client.d.ts +15 -8
- package/dist/vendor/tunnel-client/client.js +477 -407
- package/dist/vendor/tunnel-client/config.d.ts +5 -5
- package/dist/vendor/tunnel-client/config.js +5 -5
- package/dist/vendor/tunnel-client/index.d.ts +4 -4
- package/dist/vendor/tunnel-client/index.js +4 -4
- package/dist/vendor/tunnel-client/types.d.ts +19 -34
- package/dist/vendor/tunnel-client/types.js +1 -0
- package/dist/vendor/tunnel-client/ws-compat.d.ts +13 -3
- package/dist/vendor/tunnel-client/ws-compat.js +70 -12
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/skills/testsprite-onboard.skill.md +4 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* VENDOR DELTA (not upstream). Upstream's `config.ts` reads `TSTUN_*`
|
|
3
|
-
* environment variables and falls back to **hard-coded TestSprite
|
|
4
|
-
*
|
|
3
|
+
* environment variables and falls back to **hard-coded TestSprite
|
|
4
|
+
* endpoints**. Neither belongs in a package published to the public
|
|
5
5
|
* npm registry:
|
|
6
6
|
*
|
|
7
7
|
* - the endpoints are internal infrastructure names, and a default value is
|
|
@@ -23,9 +23,7 @@ export declare const DEFAULT_HEARTBEAT_MS = 10000;
|
|
|
23
23
|
/**
|
|
24
24
|
* Maximum time `start()` waits for the server's authentication Ack.
|
|
25
25
|
*
|
|
26
|
-
*
|
|
27
|
-
* windows, so a control socket cannot look ready indefinitely when the server
|
|
28
|
-
* accepted the transport but never authenticated it.
|
|
26
|
+
* Upstream default: matches the heartbeat and target-connect windows.
|
|
29
27
|
*/
|
|
30
28
|
export declare const DEFAULT_AUTH_TIMEOUT_MS = 10000;
|
|
31
29
|
/** Maximum time allowed for each plaintext TCP connect. */
|
|
@@ -34,6 +32,8 @@ export declare const DEFAULT_CONNECT_TIMEOUT_MS = 10000;
|
|
|
34
32
|
export declare const DEFAULT_TLS_HANDSHAKE_TIMEOUT_MS = 10000;
|
|
35
33
|
/** Retry window after the first failed data-plane dial. Zero retries forever. */
|
|
36
34
|
export declare const DEFAULT_DATA_PLANE_RETRY_DEADLINE_MS = 60000;
|
|
35
|
+
/** Upstream unknown-client retry window; dormant with the current capability-gated server. */
|
|
36
|
+
export declare const DEFAULT_CLIENT_UNKNOWN_RETRY_DEADLINE_MS = 120000;
|
|
37
37
|
/** Post-hello interval after which an otherwise-idle data-plane session is established. */
|
|
38
38
|
export declare const DEFAULT_DATA_PLANE_SETTLE_MS = 5000;
|
|
39
39
|
/** Delay between control/tunnel reconnect attempts. Upstream default. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* VENDOR DELTA (not upstream). Upstream's `config.ts` reads `TSTUN_*`
|
|
3
|
-
* environment variables and falls back to **hard-coded TestSprite
|
|
4
|
-
*
|
|
3
|
+
* environment variables and falls back to **hard-coded TestSprite
|
|
4
|
+
* endpoints**. Neither belongs in a package published to the public
|
|
5
5
|
* npm registry:
|
|
6
6
|
*
|
|
7
7
|
* - the endpoints are internal infrastructure names, and a default value is
|
|
@@ -23,9 +23,7 @@ export const DEFAULT_HEARTBEAT_MS = 10_000;
|
|
|
23
23
|
/**
|
|
24
24
|
* Maximum time `start()` waits for the server's authentication Ack.
|
|
25
25
|
*
|
|
26
|
-
*
|
|
27
|
-
* windows, so a control socket cannot look ready indefinitely when the server
|
|
28
|
-
* accepted the transport but never authenticated it.
|
|
26
|
+
* Upstream default: matches the heartbeat and target-connect windows.
|
|
29
27
|
*/
|
|
30
28
|
export const DEFAULT_AUTH_TIMEOUT_MS = 10_000;
|
|
31
29
|
/** Maximum time allowed for each plaintext TCP connect. */
|
|
@@ -34,6 +32,8 @@ export const DEFAULT_CONNECT_TIMEOUT_MS = 10_000;
|
|
|
34
32
|
export const DEFAULT_TLS_HANDSHAKE_TIMEOUT_MS = 10_000;
|
|
35
33
|
/** Retry window after the first failed data-plane dial. Zero retries forever. */
|
|
36
34
|
export const DEFAULT_DATA_PLANE_RETRY_DEADLINE_MS = 60_000;
|
|
35
|
+
/** Upstream unknown-client retry window; dormant with the current capability-gated server. */
|
|
36
|
+
export const DEFAULT_CLIENT_UNKNOWN_RETRY_DEADLINE_MS = 120_000;
|
|
37
37
|
/** Post-hello interval after which an otherwise-idle data-plane session is established. */
|
|
38
38
|
export const DEFAULT_DATA_PLANE_SETTLE_MS = 5_000;
|
|
39
39
|
/** Delay between control/tunnel reconnect attempts. Upstream default. */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* VENDOR DELTA (not upstream).
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* VENDOR DELTA (not upstream). The CLI adds the two dial helpers, which its
|
|
3
|
+
* port preflight reuses so the pre-charge probe dials the SAME candidate set
|
|
4
|
+
* the client will dial at run time. Upstream endpoint defaults and dormant
|
|
5
|
+
* unknown-client recovery exports are intentionally omitted.
|
|
6
6
|
*/
|
|
7
7
|
export { TunnelClient, BlockedTargetError, resolveDialCandidates, blockedTargetReason, } from './client.js';
|
|
8
8
|
export type { TunnelClientOptions, StreamOpenRequestFrame, LogLevel } from './types.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* VENDOR DELTA (not upstream).
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* VENDOR DELTA (not upstream). The CLI adds the two dial helpers, which its
|
|
3
|
+
* port preflight reuses so the pre-charge probe dials the SAME candidate set
|
|
4
|
+
* the client will dial at run time. Upstream endpoint defaults and dormant
|
|
5
|
+
* unknown-client recovery exports are intentionally omitted.
|
|
6
6
|
*/
|
|
7
7
|
export { TunnelClient, BlockedTargetError, resolveDialCandidates, blockedTargetReason, } from './client.js';
|
|
8
8
|
export { ErrCode } from './types.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
2
|
+
export type TunnelTransport = "tls" | "plaintext";
|
|
2
3
|
export declare enum ErrCode {
|
|
3
4
|
AuthFailed = "0001",
|
|
4
5
|
ControlDisconnected = "0002",
|
|
@@ -6,7 +7,8 @@ export declare enum ErrCode {
|
|
|
6
7
|
TargetConnectFailed = "0004",
|
|
7
8
|
StreamFailed = "0005",
|
|
8
9
|
BlockedTargetRejected = "0006",
|
|
9
|
-
DataPlaneUnreachable = "0007"
|
|
10
|
+
DataPlaneUnreachable = "0007",
|
|
11
|
+
ClientUnknown = "0008"
|
|
10
12
|
}
|
|
11
13
|
export interface TunnelClientError {
|
|
12
14
|
code: ErrCode;
|
|
@@ -15,42 +17,29 @@ export interface TunnelClientError {
|
|
|
15
17
|
export interface TunnelClientOptions {
|
|
16
18
|
clientId: string;
|
|
17
19
|
secret: string;
|
|
18
|
-
/**
|
|
19
|
-
* VENDOR DELTA: required, not optional. The endpoint defaults upstream
|
|
20
|
-
* carries are hard-coded TestSprite dev hostnames; they are gone here and
|
|
21
|
-
* both values come from `POST /api/cli/v1/tunnel`. See ./config.ts.
|
|
22
|
-
*/
|
|
20
|
+
/** CLI endpoints must come from the tunnel mint response. */
|
|
23
21
|
controlUrl: string;
|
|
24
|
-
/**
|
|
22
|
+
/** Legacy unencrypted data-plane address (`host:port` or `[v6]:port`). */
|
|
25
23
|
tunnelAddr: string;
|
|
26
|
-
/**
|
|
27
|
-
* TLS `host:port` (or `[v6]:port`) for the tunnel DATA plane. When set,
|
|
28
|
-
* transport is fixed to TLS and `tunnelAddr` is never dialled as fallback.
|
|
29
|
-
*/
|
|
24
|
+
/** TLS data-plane address (`host:port` or `[v6]:port`). Takes precedence over `tunnelAddr`. */
|
|
30
25
|
tunnelTlsAddr?: string;
|
|
31
|
-
/** TLS SNI
|
|
26
|
+
/** TLS SNI and certificate hostname. Defaults to the DNS host in `tunnelTlsAddr`. */
|
|
32
27
|
tunnelTlsServername?: string;
|
|
33
|
-
/**
|
|
28
|
+
/** Additional PEM roots appended to Node's default trust store. */
|
|
34
29
|
tunnelTlsCa?: string | Buffer | Array<string | Buffer>;
|
|
35
|
-
/** Maximum
|
|
36
|
-
connectTimeoutMs?: number;
|
|
37
|
-
/** Maximum time to complete each TLS connect + handshake. Defaults to 10 seconds. */
|
|
30
|
+
/** Maximum wait for the data-plane TLS handshake; defaults to 10 seconds. */
|
|
38
31
|
tlsHandshakeTimeoutMs?: number;
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
* seconds; `0` retries forever.
|
|
43
|
-
*/
|
|
32
|
+
/** Maximum wait for a plaintext data-plane TCP connection; defaults to 10 seconds. */
|
|
33
|
+
connectTimeoutMs?: number;
|
|
34
|
+
/** Continuous data-plane failure episode; defaults to 60 seconds. Zero retries forever. */
|
|
44
35
|
dataPlaneRetryDeadlineMs?: number;
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
/** Continuous unknown-client episode; defaults to 120 seconds. Zero retries forever. */
|
|
37
|
+
clientUnknownRetryDeadlineMs?: number;
|
|
38
|
+
/** Called before retrying an unknown client; can re-register the same ID and secret. */
|
|
39
|
+
onClientUnknown?: () => Promise<boolean | void>;
|
|
40
|
+
/** Open-session stability period that establishes the data plane; defaults to 5 seconds. */
|
|
49
41
|
dataPlaneSettleMs?: number;
|
|
50
|
-
/**
|
|
51
|
-
* VENDOR DELTA: maximum time `start()` waits for the current control
|
|
52
|
-
* connection's first Ack, which is the server's authentication acknowledgement.
|
|
53
|
-
*/
|
|
42
|
+
/** Maximum wait for the initial control connection's authentication Ack; defaults to 10 seconds. */
|
|
54
43
|
authTimeoutMs?: number;
|
|
55
44
|
heartbeatMs?: number;
|
|
56
45
|
reconnectMs?: number;
|
|
@@ -70,11 +59,7 @@ export interface TunnelClientOptions {
|
|
|
70
59
|
*/
|
|
71
60
|
allowPrivateNetworkTarget?: boolean;
|
|
72
61
|
onError?(e: TunnelClientError): void;
|
|
73
|
-
/**
|
|
74
|
-
* VENDOR DELTA (not upstream): where log lines go. Upstream writes them to
|
|
75
|
-
* `console.log`/`console.warn`, i.e. STDOUT, which would corrupt this CLI's
|
|
76
|
-
* `--output json` contract. Absent -> stderr.
|
|
77
|
-
*/
|
|
62
|
+
/** CLI logs use the injected sink; the default writes only to stderr. */
|
|
78
63
|
logSink?(level: LogLevel, line: string): void;
|
|
79
64
|
}
|
|
80
65
|
export type ClientToServerControlMessage = {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
* `WebSocket.close()` on an OPEN connection sends a Close frame and sets the
|
|
33
33
|
* ready state to CLOSING — nothing more. It does not abort the underlying
|
|
34
34
|
* connection and does not time out; that only happens for a CONNECTING
|
|
35
|
-
* socket (`failWebsocketConnection`, upstream `client.ts`
|
|
35
|
+
* socket (`failWebsocketConnection`, upstream `client.ts` stop-on-CONNECTING
|
|
36
36
|
* territory). If the peer never sends its own Close frame back — a redeploy
|
|
37
37
|
* mid-handshake, a proxy that swallows the FIN, a server too busy to answer —
|
|
38
38
|
* the ready state sits at CLOSING forever, the JS `'close'` event never
|
|
@@ -114,6 +114,14 @@ type PingListener = (data: Buffer) => void;
|
|
|
114
114
|
* to hear about it.
|
|
115
115
|
*/
|
|
116
116
|
export declare const CLOSE_GRACE_MS = 1200;
|
|
117
|
+
/** The fields undici publishes for a request about to write its headers. */
|
|
118
|
+
interface UpgradeRequest {
|
|
119
|
+
upgrade?: unknown;
|
|
120
|
+
path?: unknown;
|
|
121
|
+
origin?: unknown;
|
|
122
|
+
}
|
|
123
|
+
/** Does this `sendHeaders` request belong to the WebSocket upgrade for `target`? */
|
|
124
|
+
export declare function upgradeRequestMatchesTarget(request: UpgradeRequest | undefined, target: URL): boolean;
|
|
117
125
|
/** The subset of `undici:client:connected`'s `connectParams` this filter reads. */
|
|
118
126
|
export interface ConnectParams {
|
|
119
127
|
hostname?: unknown;
|
|
@@ -161,7 +169,7 @@ export declare class WsCompatSocket {
|
|
|
161
169
|
static readonly CONNECTING = 0;
|
|
162
170
|
static readonly OPEN = 1;
|
|
163
171
|
private readonly socket;
|
|
164
|
-
/** Captured via
|
|
172
|
+
/** Captured via connected or the upgrade's sendHeaders event, including reused sockets. */
|
|
165
173
|
private rawSocket;
|
|
166
174
|
private closeListener;
|
|
167
175
|
private closeSettled;
|
|
@@ -173,7 +181,9 @@ export declare class WsCompatSocket {
|
|
|
173
181
|
* `net.Socket` for THIS connection, filtered by target host/port so an
|
|
174
182
|
* unrelated concurrent undici connection elsewhere in the process (e.g.
|
|
175
183
|
* this CLI's own HTTP polling) is never mistaken for it. See the class
|
|
176
|
-
* docstring for why `close()` needs this at all.
|
|
184
|
+
* docstring for why `close()` needs this at all. The sendHeaders fallback
|
|
185
|
+
* also checks the upgrade path and query, then ends both subscriptions.
|
|
186
|
+
* Returns an idempotent
|
|
177
187
|
* unsubscribe closure. Never throws: a diagnostics hook failing must not
|
|
178
188
|
* break the connection it exists only to make teardown more graceful for.
|
|
179
189
|
*/
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
* `WebSocket.close()` on an OPEN connection sends a Close frame and sets the
|
|
33
33
|
* ready state to CLOSING — nothing more. It does not abort the underlying
|
|
34
34
|
* connection and does not time out; that only happens for a CONNECTING
|
|
35
|
-
* socket (`failWebsocketConnection`, upstream `client.ts`
|
|
35
|
+
* socket (`failWebsocketConnection`, upstream `client.ts` stop-on-CONNECTING
|
|
36
36
|
* territory). If the peer never sends its own Close frame back — a redeploy
|
|
37
37
|
* mid-handshake, a proxy that swallows the FIN, a server too busy to answer —
|
|
38
38
|
* the ready state sits at CLOSING forever, the JS `'close'` event never
|
|
@@ -118,6 +118,42 @@ export const CLOSE_GRACE_MS = 1200;
|
|
|
118
118
|
* — payload is `{ socket, connectParams, connector }`.
|
|
119
119
|
*/
|
|
120
120
|
const CONNECTED_CHANNEL = 'undici:client:connected';
|
|
121
|
+
/**
|
|
122
|
+
* Companion channel for the case `CONNECTED_CHANNEL` cannot see: the process-
|
|
123
|
+
* global dispatcher may hand the upgrade request an already-open pooled
|
|
124
|
+
* keep-alive connection (e.g. one an earlier API call left idle), in which
|
|
125
|
+
* case no dial happens and no `connected` event fires. `sendHeaders` is
|
|
126
|
+
* published for every request on whichever socket carries it, upgrade
|
|
127
|
+
* requests included — payload is `{ request, headers, socket }`.
|
|
128
|
+
*/
|
|
129
|
+
const SEND_HEADERS_CHANNEL = 'undici:client:sendHeaders';
|
|
130
|
+
/** Does this `sendHeaders` request belong to the WebSocket upgrade for `target`? */
|
|
131
|
+
export function upgradeRequestMatchesTarget(request, target) {
|
|
132
|
+
if (typeof request?.upgrade !== 'string' ||
|
|
133
|
+
request.upgrade.toLowerCase() !== 'websocket' ||
|
|
134
|
+
typeof request.path !== 'string') {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
// undici converts ws/wss to http/https for the handshake. A forward
|
|
139
|
+
// proxy can put the target's absolute URL in path and its own origin in
|
|
140
|
+
// origin; in that case the absolute request target identifies the peer.
|
|
141
|
+
const absolutePath = /^https?:\/\//.test(request.path);
|
|
142
|
+
if (!absolutePath && typeof request.origin !== 'string')
|
|
143
|
+
return false;
|
|
144
|
+
const origin = new URL(absolutePath ? request.path : request.origin);
|
|
145
|
+
const protocol = target.protocol === 'wss:' ? 'https:' : 'http:';
|
|
146
|
+
const defaultPort = protocol === 'https:' ? '443' : '80';
|
|
147
|
+
const path = absolutePath ? `${origin.pathname}${origin.search}` : request.path;
|
|
148
|
+
return (origin.protocol === protocol &&
|
|
149
|
+
origin.hostname === target.hostname &&
|
|
150
|
+
(origin.port || defaultPort) === (target.port || defaultPort) &&
|
|
151
|
+
path === `${target.pathname}${target.search}`);
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
121
157
|
/**
|
|
122
158
|
* Does this `undici:client:connected` event belong to the WebSocket we are
|
|
123
159
|
* trying to capture?
|
|
@@ -181,7 +217,7 @@ export class WsCompatSocket {
|
|
|
181
217
|
static CONNECTING = 0;
|
|
182
218
|
static OPEN = 1;
|
|
183
219
|
socket;
|
|
184
|
-
/** Captured via
|
|
220
|
+
/** Captured via connected or the upgrade's sendHeaders event, including reused sockets. */
|
|
185
221
|
rawSocket;
|
|
186
222
|
closeListener;
|
|
187
223
|
closeSettled = false;
|
|
@@ -189,22 +225,32 @@ export class WsCompatSocket {
|
|
|
189
225
|
unsubscribeConnected;
|
|
190
226
|
constructor(url) {
|
|
191
227
|
this.unsubscribeConnected = this.captureRawSocket(url);
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
228
|
+
try {
|
|
229
|
+
this.socket = new UndiciWebSocket(url);
|
|
230
|
+
// Whichever comes first, the capture window is over the moment this
|
|
231
|
+
// connection attempt is decided — see captureRawSocket's docstring.
|
|
232
|
+
this.socket.addEventListener('open', () => this.unsubscribeConnected(), { once: true });
|
|
233
|
+
this.socket.addEventListener('error', () => this.unsubscribeConnected(), { once: true });
|
|
234
|
+
this.socket.addEventListener('close', (ev) => this.settleClose(ev.code, Buffer.from(ev.reason ?? '', 'utf8')), { once: true });
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
this.unsubscribeConnected();
|
|
238
|
+
throw error;
|
|
239
|
+
}
|
|
197
240
|
}
|
|
198
241
|
/**
|
|
199
242
|
* Subscribe to `undici:client:connected` just long enough to grab the raw
|
|
200
243
|
* `net.Socket` for THIS connection, filtered by target host/port so an
|
|
201
244
|
* unrelated concurrent undici connection elsewhere in the process (e.g.
|
|
202
245
|
* this CLI's own HTTP polling) is never mistaken for it. See the class
|
|
203
|
-
* docstring for why `close()` needs this at all.
|
|
246
|
+
* docstring for why `close()` needs this at all. The sendHeaders fallback
|
|
247
|
+
* also checks the upgrade path and query, then ends both subscriptions.
|
|
248
|
+
* Returns an idempotent
|
|
204
249
|
* unsubscribe closure. Never throws: a diagnostics hook failing must not
|
|
205
250
|
* break the connection it exists only to make teardown more graceful for.
|
|
206
251
|
*/
|
|
207
252
|
captureRawSocket(url) {
|
|
253
|
+
let unsubscribe = () => { };
|
|
208
254
|
try {
|
|
209
255
|
const target = typeof url === 'string' ? new URL(url) : url;
|
|
210
256
|
const channel = diagnosticsChannel.channel(CONNECTED_CHANNEL);
|
|
@@ -215,10 +261,24 @@ export class WsCompatSocket {
|
|
|
215
261
|
channel.unsubscribe(onConnected);
|
|
216
262
|
}
|
|
217
263
|
};
|
|
264
|
+
const sendChannel = diagnosticsChannel.channel(SEND_HEADERS_CHANNEL);
|
|
265
|
+
const onSendHeaders = (message) => {
|
|
266
|
+
const { socket, request } = (message ?? {});
|
|
267
|
+
if (socket !== undefined && upgradeRequestMatchesTarget(request, target)) {
|
|
268
|
+
this.rawSocket = socket;
|
|
269
|
+
unsubscribe();
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
unsubscribe = () => {
|
|
273
|
+
channel.unsubscribe(onConnected);
|
|
274
|
+
sendChannel.unsubscribe(onSendHeaders);
|
|
275
|
+
};
|
|
218
276
|
channel.subscribe(onConnected);
|
|
219
|
-
|
|
277
|
+
sendChannel.subscribe(onSendHeaders);
|
|
278
|
+
return unsubscribe;
|
|
220
279
|
}
|
|
221
280
|
catch {
|
|
281
|
+
unsubscribe();
|
|
222
282
|
// Degrade to "no captured socket": close() still settles via the
|
|
223
283
|
// synthetic-close path, just without the unref step.
|
|
224
284
|
return () => { };
|
|
@@ -249,9 +309,6 @@ export class WsCompatSocket {
|
|
|
249
309
|
// target of the synthetic close below, and either path must reach
|
|
250
310
|
// this exact listener exactly once. See the class docstring.
|
|
251
311
|
this.closeListener = listener;
|
|
252
|
-
this.socket.addEventListener('close', (ev) => {
|
|
253
|
-
this.settleClose(ev.code, Buffer.from(ev.reason ?? '', 'utf8'));
|
|
254
|
-
});
|
|
255
312
|
return this;
|
|
256
313
|
case 'ping':
|
|
257
314
|
// See the module docstring: undici answers PING internally, so there
|
|
@@ -265,6 +322,7 @@ export class WsCompatSocket {
|
|
|
265
322
|
this.socket.send(data);
|
|
266
323
|
}
|
|
267
324
|
close(code, reason) {
|
|
325
|
+
this.unsubscribeConnected();
|
|
268
326
|
this.socket.close(code, reason);
|
|
269
327
|
this.armCloseGrace();
|
|
270
328
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.14.0";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -117,8 +117,8 @@ testsprite project docs upload ./prd.md --project <projectId> --role prd # opt
|
|
|
117
117
|
testsprite test plan generate --project <projectId>
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
-
Only missing stages run. Frontend exploration can take minutes
|
|
121
|
-
|
|
120
|
+
Only missing stages run. Frontend exploration can take minutes. If cut off, the
|
|
121
|
+
running stage finishes; re-run to continue. If inputs are processing, wait and re-run.
|
|
122
122
|
|
|
123
123
|
Review titles and steps against the source. Drop nonexistent flows, duplicates,
|
|
124
124
|
and vague assertions before accepting.
|
|
@@ -181,8 +181,8 @@ runs keep working after the token expires. A hardcoded token expires within hour
|
|
|
181
181
|
key can't be rotated centrally — `test create` emits a `[warn]` on an inlined credential; treat it
|
|
182
182
|
as a must-fix.
|
|
183
183
|
|
|
184
|
-
Each assertion must name an observable element, text, URL, count, or status
|
|
185
|
-
|
|
184
|
+
Each assertion must name an observable element, text, URL, count, or status;
|
|
185
|
+
vague ones like "verify it works" create false passes.
|
|
186
186
|
|
|
187
187
|
Aim for ~8–15 tests covering the core flows. Don't pad.
|
|
188
188
|
|