quic: multiple fixups and updates

Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/59342
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
This commit is contained in:
James M Snell committed 2025-09-07 19:29:01 -07:00
1 parent a6c5d27739
commit cd9fd09a27
44 files changed
+646 -360

No files matched your search

@@ -142,4 +142,7 @@ for (const [, envVar, config] of nodeOptionsCC.matchAll(addOptionRE)) {
// add alias handling
manPagesOptions.delete('-trace-events-enabled');
// TODO(@jasnell): Need to determine why the documentation for this option is not being recognized
manPagesOptions.delete('-no-experimental-quic');
assert.strictEqual(manPagesOptions.size, 0, `Man page options not documented: ${[...manPagesOptions]}`);
@@ -131,9 +131,7 @@ assert(undocumented.delete('--no-verify-base-objects'));
assert(undocumented.delete('--trace-promises'));
assert(undocumented.delete('--no-trace-promises'));
assert(undocumented.delete('--experimental-quic'));
if (common.hasQuic) {
assert(undocumented.delete('--no-experimental-quic'));
}
assert(undocumented.delete('--no-experimental-quic'));
// Remove negated versions of the flags.
for (const flag of undocumented) {
+1
View File
@@ -10,6 +10,7 @@ const expectedKeys = new Map([
['uv', ['boolean']],
['ipv6', ['boolean']],
['openssl_is_boringssl', ['boolean']],
['quic', ['boolean']],
['tls_alpn', ['boolean']],
['tls_sni', ['boolean']],
['tls_ocsp', ['boolean']],
+2
View File
@@ -15,6 +15,8 @@ const expected_keys = [
'v8',
'zlib',
'nghttp2',
'nghttp3',
'ngtcp2',
'napi',
'llhttp',
'uvwasi',
+32 -64
View File
@@ -1,82 +1,50 @@
// Flags: --experimental-quic --no-warnings
'use strict';
const { hasQuic } = require('../common');
const { Buffer } = require('node:buffer');
const common = require('../common');
const { ok, strictEqual } = require('node:assert');
const {
describe,
it,
} = require('node:test');
// TODO(@jasnell): Temporarily skip the test on mac until we can figure
// out while it is failing on macs in CI but running locally on macs ok.
const isMac = process.platform === 'darwin';
const skip = isMac || !hasQuic;
async function readAll(readable, resolve) {
const chunks = [];
for await (const chunk of readable) {
chunks.push(chunk);
}
resolve(Buffer.concat(chunks));
if (!common.hasQuic) {
common.skip('QUIC is not enabled');
}
describe('quic basic server/client handshake works', { skip }, async () => {
const { createPrivateKey } = require('node:crypto');
const fixtures = require('../common/fixtures');
const keys = createPrivateKey(fixtures.readKey('agent1-key.pem'));
const certs = fixtures.readKey('agent1-cert.pem');
const { createPrivateKey } = require('node:crypto');
const fixtures = require('../common/fixtures');
const keys = createPrivateKey(fixtures.readKey('agent1-key.pem'));
const certs = fixtures.readKey('agent1-cert.pem');
const {
listen,
connect,
} = require('node:quic');
const {
listen,
connect,
} = require('node:quic');
const {
strictEqual,
ok,
} = require('node:assert');
it('a quic client can connect to a quic server in the same process', async () => {
const p1 = Promise.withResolvers();
const p2 = Promise.withResolvers();
const p3 = Promise.withResolvers();
const p1 = Promise.withResolvers();
const p2 = Promise.withResolvers();
const serverEndpoint = await listen((serverSession) => {
(async () => {
const serverEndpoint = await listen((serverSession) => {
serverSession.opened.then((info) => {
strictEqual(info.servername, 'localhost');
strictEqual(info.protocol, 'h3');
strictEqual(info.cipher, 'TLS_AES_128_GCM_SHA256');
p1.resolve();
});
serverSession.onstream = (stream) => {
readAll(stream.readable, p3.resolve).then(() => {
serverSession.close();
});
};
}, { keys, certs });
ok(serverEndpoint.address !== undefined);
const clientSession = await connect(serverEndpoint.address);
clientSession.opened.then((info) => {
serverSession.opened.then((info) => {
strictEqual(info.servername, 'localhost');
strictEqual(info.protocol, 'h3');
strictEqual(info.cipher, 'TLS_AES_128_GCM_SHA256');
p2.resolve();
});
const body = new Blob(['hello']);
const stream = await clientSession.createUnidirectionalStream({
body,
p1.resolve();
serverSession.close();
});
ok(stream);
}, { keys, certs });
const { 2: data } = await Promise.all([p1.promise, p2.promise, p3.promise]);
clientSession.close();
strictEqual(Buffer.from(data).toString(), 'hello');
ok(serverEndpoint.address !== undefined);
const clientSession = await connect(serverEndpoint.address);
clientSession.opened.then((info) => {
strictEqual(info.servername, 'localhost');
strictEqual(info.protocol, 'h3');
strictEqual(info.cipher, 'TLS_AES_128_GCM_SHA256');
p2.resolve();
});
});
await Promise.all([p1.promise, p2.promise]);
clientSession.close();
})().then(common.mustCall());