| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2813,9 +2813,9 @@ bool Session::ReadPacket(const uint8_t* data, | |||
| 2813 | 2813 | Debug(this, "Session successfully received %zu-byte packet", len); | |
| 2814 | 2814 | if (!is_destroyed()) [[likely]] { | |
| 2815 | 2815 | STAT_INCREMENT_N(Stats, bytes_received, len); | |
| 2816 | - // Process deferred operations that couldn't run inside callback | ||
| 2817 | - // scopes (e.g., HTTP/3 GOAWAY handling that calls into JS). | ||
| 2818 | - application().PostReceive(); | ||
| 2816 | + // Process deferred application operations after ALPN selection - not | ||
| 2817 | + // necessarily resolved yet as ClientHello can span multiple packets. | ||
| 2818 | + if (has_application()) application().PostReceive(); | ||
| 2819 | 2819 | // Surface a server session to JS once its ClientHello has been | |
| 2820 | 2820 | // processed (OnSelectAlpn fired: SNI + ALPN are known and reliable). | |
| 2821 | 2821 | // Held first-flight events - including 0-RTT request streams - replay | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,60 @@ | |||
| 1 | + // Flags: --experimental-quic --experimental-stream-iter --no-warnings | ||
| 2 | + | ||
| 3 | + // A large post-quantum key share splits the ClientHello across QUIC Initial | ||
| 4 | + // packets. The server must accept the incomplete first packet before ALPN has | ||
| 5 | + // selected its application, then complete the handshake and process streams. | ||
| 6 | + | ||
| 7 | + import { hasQuic, skip, mustCall } from '../common/index.mjs'; | ||
| 8 | + import assert from 'node:assert'; | ||
| 9 | + import * as fixtures from '../common/fixtures.mjs'; | ||
| 10 | + | ||
| 11 | + if (!hasQuic) { | ||
| 12 | + skip('QUIC is not enabled'); | ||
| 13 | + } | ||
| 14 | + | ||
| 15 | + const { createPrivateKey } = await import('node:crypto'); | ||
| 16 | + const { listen, connect } = await import('node:quic'); | ||
| 17 | + const { bytes } = await import('stream/iter'); | ||
| 18 | + | ||
| 19 | + const key = createPrivateKey(fixtures.readKey('agent1-key.pem')); | ||
| 20 | + const cert = fixtures.readKey('agent1-cert.pem'); | ||
| 21 | + const alpn = 'quic-multipacket-clienthello'; | ||
| 22 | + const groups = 'X25519MLKEM768'; | ||
| 23 | + const streamReceived = Promise.withResolvers(); | ||
| 24 | + | ||
| 25 | + const endpoint = await listen(mustCall(async (session) => { | ||
| 26 | + const info = await session.opened; | ||
| 27 | + assert.strictEqual(session.alpnProtocol, alpn); | ||
| 28 | + assert.strictEqual(info.cipherVersion, 'TLSv1.3'); | ||
| 29 | + | ||
| 30 | + session.onstream = mustCall(async (stream) => { | ||
| 31 | + assert.strictEqual( | ||
| 32 | + Buffer.from(await bytes(stream)).toString(), | ||
| 33 | + 'application event survived', | ||
| 34 | + ); | ||
| 35 | + stream.writer.endSync(); | ||
| 36 | + await stream.closed; | ||
| 37 | + streamReceived.resolve(); | ||
| 38 | + }); | ||
| 39 | + }), { | ||
| 40 | + host: '127.0.0.1', | ||
| 41 | + port: 0, | ||
| 42 | + alpn: [alpn], | ||
| 43 | + groups, | ||
| 44 | + sni: { '*': { keys: [key], certs: [cert] } }, | ||
| 45 | + }); | ||
| 46 | + | ||
| 47 | + const session = await connect(endpoint.address, { | ||
| 48 | + alpn, | ||
| 49 | + groups, | ||
| 50 | + servername: 'localhost', | ||
| 51 | + verifyPeer: 'manual', | ||
| 52 | + }); | ||
| 53 | + | ||
| 54 | + await session.opened; | ||
| 55 | + const stream = await session.createBidirectionalStream({ | ||
| 56 | + body: 'application event survived', | ||
| 57 | + }); | ||
| 58 | + await Promise.all([stream.closed, streamReceived.promise]); | ||
| 59 | + await session.close(); | ||
| 60 | + await endpoint.close(); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments