Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion test/js/node/tls/node-tls-connect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5627,7 +5627,8 @@ describe("connect(port) on a TLSSocket that runs over a transport the caller han
const transport = proxied ? new SocketProxy(raw) : raw;
const client = wrap(transport);
try {
await once(client, established);
// The server's handshake ends after the client's: it has yet to read the client's Finished.
await Promise.all([once(client, established), once(server, "secureConnection")]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 (optional) CI runners get a silent timeout hang instead of a diagnosable failure when the server side of the handshake fails after the client's side completed. At test/js/node/tls/node-tls-connect.test.ts:5631 the Promise.all awaits once(server, "secureConnection"), but a server-side handshake failure is reported through "tlsClientError" (src/js/node/net.ts:1361, 1495), never as a server "error", so events.once never rejects. The base branch awaited only the client and then failed fast at expect(accepted).toBe(1). Fix: wire every failure signal to reject the awaited promise: a server "tlsClientError" listener and a client "close"/"error" listener racing the Promise.all, as REVIEW.md requires for awaited conditions.

Why this was flagged

Trigger: the client finishes its TLS 1.3 handshake (once(client, established) resolves at test/js/node/tls/node-tls-connect.test.ts:5631) and the server then fails or never completes its side. Server failures are emitted as "tlsClientError" (net.ts:1361, net.ts:1495), not "error", so events.once(server, "secureConnection") never rejects. Once the client promise has settled, the error listener that events.once installed on the client is removed, so a later client "error" or "close" cannot reject the Promise.all either. The test then hangs until the per-test timeout with no message. On the base branch the same condition proceeded past the await, called client.connect, and failed quickly at expect(accepted).toBe(1) with "Expected: 1 Received: 0". REVIEW.md 'Tests reviewers reject' requires wiring every failure event to reject the awaited promise. Remedy: race the Promise.all against a rejecting listener on server "tlsClientError" and client "close".

Verification: test/js/node/tls/node-tls-connect.test.ts:5631 once(server, "secureConnection") has no failure wiring: in src/js/node/net.ts the handshake-failure path does server?.emit("tlsClientError", ...) (line 1495), never error on server, so it never settles and the test runs into the per-test timeout. On the base branch the same situation failed fast at expect(accepted).toBe(1) (line 5657).

// Not from inside the handshake callback.
await new Promise(resolve => setImmediate(resolve));
const errored = once(client, "error");
Expand Down
Loading