Files
node/test/parallel/test-quic-callback-error-onhandshake.mjs
T
James M Snell cf91d181fb quic: complete the internal implementation of QUIC
Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode:Opus 4.6
PR-URL: https://github.com/nodejs/node/pull/62876
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
2026-05-05 19:16:19 -07:00

37 lines
1.1 KiB
JavaScript

// Flags: --experimental-quic --no-warnings
// Test: onhandshake callback error handling.
// A sync throw in onhandshake destroys the session via safeCallbackInvoke.
// The error is delivered to the onerror callback and the session's
// closed promise rejects with the error.
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
if (!hasQuic) {
skip('QUIC is not enabled');
}
const { listen, connect } = await import('../common/quic.mjs');
const testError = new Error('onhandshake throw');
const serverEndpoint = await listen(mustCall(async (serverSession) => {
await serverSession.closed;
}), { transportParams: { maxIdleTimeout: 1 } });
const clientSession = await connect(serverEndpoint.address, {
transportParams: { maxIdleTimeout: 1 },
onhandshake() {
throw testError;
},
onerror: mustCall((err) => {
assert.strictEqual(err, testError);
}),
});
// The session's closed should reject with the error from the throw.
await assert.rejects(clientSession.closed, testError);
await serverEndpoint.close();