mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: https://github.com/nodejs/node/pull/64716 Reviewed-By: Ethan Arrowood <ethan@arrowood.dev> Reviewed-By: Aviv Keller <me@aviv.sh>
36 lines
1.0 KiB
JavaScript
36 lines
1.0 KiB
JavaScript
// Flags: --experimental-quic --no-warnings
|
|
|
|
// Test: onerror set via connect() options.
|
|
// The onerror callback can be provided in the options object at
|
|
// session creation time to avoid race conditions with errors that
|
|
// occur during or immediately after the handshake.
|
|
|
|
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 transportParams = { maxIdleTimeout: 1 };
|
|
const testError = new Error('destroy with error');
|
|
|
|
const serverEndpoint = await listen(mustCall(async (serverSession) => {
|
|
await serverSession.closed;
|
|
}), { transportParams });
|
|
|
|
const clientSession = await connect(serverEndpoint.address, {
|
|
transportParams,
|
|
onerror: mustCall((err) => {
|
|
assert.strictEqual(err, testError);
|
|
}),
|
|
});
|
|
await clientSession.opened;
|
|
|
|
clientSession.destroy(testError);
|
|
|
|
await assert.rejects(clientSession.closed, testError);
|
|
await serverEndpoint.close();
|