@@ -305,7 +305,11 @@ unidirectional (data flows in only one direction). The `quic` module provides
305305separate APIs for creating each kind:
306306[ ` session.createBidirectionalStream() ` ] [ ] and
307307[ ` session.createUnidirectionalStream() ` ] [ ] . Streams initiated by a remote
308- peer are delivered via the [ ` session.onstream ` ] [ ] callback.
308+ peer are delivered via the [ ` session.onstream ` ] [ ] callback. When the
309+ negotiated application protocol supports the stream-level callbacks (e.g.
310+ HTTP/3) and any of them are configured, incoming streams can instead be
311+ consumed entirely through those callbacks (such as ` onheaders ` ) and
312+ registering ` onstream ` is optional.
309313
310314There are two ways to write data to a stream:
311315
@@ -409,7 +413,9 @@ A typical client session progresses through these stages:
409413
410414On the server side, call [ ` quic.listen() ` ] [ ] with a callback. The callback
411415fires for each incoming session after the TLS handshake begins. Incoming
412- streams arrive via the [ ` session.onstream ` ] [ ] callback.
416+ streams arrive via the [ ` session.onstream ` ] [ ] callback, or, for HTTP/3
417+ sessions with stream-level callbacks configured, directly through those
418+ callbacks (see the [ minimal HTTP/3 server] [ ] example).
413419
414420[ ` session.destroy() ` ] [ ] is available for immediate teardown — all open streams
415421are destroyed and the session is closed without waiting for them to finish.
@@ -1110,6 +1116,13 @@ added: v23.8.0
11101116
11111117The callback to invoke when a new stream is initiated by a remote peer. Read/write.
11121118
1119+ If no ` onstream ` callback is set and the stream has no other consumer, an
1120+ incoming stream is destroyed on arrival and a warning is emitted. Stream-level
1121+ callbacks (such as ` onheaders ` ) count as a consumer when the negotiated
1122+ application protocol supports them (e.g. HTTP/3), so an HTTP/3 server that
1123+ handles requests entirely through those callbacks does not need to set
1124+ ` onstream ` .
1125+
11131126### ` session.ondatagram `
11141127
11151128<!-- YAML
@@ -4008,7 +4021,9 @@ import { listen } from 'node:quic';
40084021const encoder = new TextEncoder ();
40094022
40104023const endpoint = await listen ((session ) => {
4011- // The session.onstream callback fires for each new client-initiated stream.
4024+ // The session.onstream callback fires for each new client-initiated
4025+ // stream. It is optional here: with `onheaders` configured below,
4026+ // request streams are consumed through the stream-level callbacks.
40124027}, {
40134028 sni: { ' *' : { keys: [defaultKey], certs: [defaultCert] } },
40144029 // ALPN defaults to 'h3'.
@@ -4642,5 +4657,6 @@ throughput issues caused by flow control.
46424657[`stream.writer`]: #streamwriter
46434658[`writer.fail()`]: #streamwriter
46444659[`writer.fail(reason)`]: #streamwriter
4660+ [minimal HTTP/3 server]: #minimal-http3-server
46454661[qlog]: https://datatracker.ietf.org/doc/draft-ietf-quic-qlog-main-schema/
46464662[qvis]: https://qvis.quictools.info/
0 commit comments