mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +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.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
// Flags: --experimental-quic --no-warnings
|
|
|
|
// Test: session created and immediately destroyed.
|
|
// Calling destroy() on a session that hasn't completed handshake should
|
|
// not crash. The opened and closed promises should settle appropriately.
|
|
|
|
import { hasQuic, skip, mustNotCall } from '../common/index.mjs';
|
|
import assert from 'node:assert';
|
|
|
|
if (!hasQuic) {
|
|
skip('QUIC is not enabled');
|
|
}
|
|
|
|
const { listen, connect } = await import('../common/quic.mjs');
|
|
|
|
// The client destroys before handshake completes, so the server
|
|
// should never see a session.
|
|
const serverEndpoint = await listen(mustNotCall(), {
|
|
transportParams: { maxIdleTimeout: 1 },
|
|
});
|
|
|
|
const clientSession = await connect(serverEndpoint.address, {
|
|
transportParams: { maxIdleTimeout: 1 },
|
|
});
|
|
|
|
// Destroy immediately without waiting for opened.
|
|
clientSession.destroy();
|
|
|
|
assert.strictEqual(clientSession.destroyed, true);
|
|
|
|
// Opened may reject (session destroyed before handshake completed)
|
|
// or resolve if handshake completed fast enough.
|
|
// Closed should resolve (destroy without error).
|
|
await clientSession.closed;
|
|
await serverEndpoint.close();
|