From 437760dbf42b428c2d0367e9e2189285dafa9762 Mon Sep 17 00:00:00 2001 From: Vishal Ranaut Date: Sun, 31 May 2026 21:52:48 +0530 Subject: [PATCH 1/2] quic: add missing documentation for stream.stopSending() and stream.resetStream() --- doc/api/quic.md | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/doc/api/quic.md b/doc/api/quic.md index 5ecac022a3c83b..24f215046c0773 100644 --- a/doc/api/quic.md +++ b/doc/api/quic.md @@ -2266,6 +2266,72 @@ The following body source types are supported: Throws `ERR_INVALID_STATE` if the outbound is already configured or if the writer has been accessed. +### `stream.resetStream([code])` + + + +* `code` {number|bigint} The application error code to include in the + `RESET_STREAM` frame sent to the peer. Numbers are coerced to `BigInt`. + **Default:** `0n`. + +Sends a `RESET_STREAM` frame to the peer, signalling that this end will +not send any more data on this stream. This half-closes the stream in the +WRITE direction only — the readable side (if any) is unaffected and can +continue receiving data from the peer. + +If the stream has already been destroyed, this is a no-op. + +This is useful for WebTransport and other application protocols that need +independent half-closing per direction without tearing down the entire +stream. + +```mjs +import { connect } from 'node:quic'; + +const session = await connect('localhost:4567', { alpn: 'myproto' }); +const stream = await session.createBidirectionalStream(); + +// Abort the writable side with application error code 42. +stream.resetStream(42n); +``` + +See [Aborting a stream][] for an overview of all stream-abort APIs. + +### `stream.stopSending([code])` + + + +* `code` {number|bigint} The application error code to include in the + `STOP_SENDING` frame sent to the peer. Numbers are coerced to `BigInt`. + **Default:** `0n`. + +Sends a `STOP_SENDING` frame to the peer, requesting that the peer stop +sending data on this stream. This half-closes the stream in the READ +direction only — the writable side (if any) is unaffected and can +continue sending data to the peer. + +If the stream has already been destroyed, this is a no-op. + +This is useful for WebTransport and other application protocols that need +independent half-closing per direction without tearing down the entire +stream. + +```mjs +import { connect } from 'node:quic'; + +const session = await connect('localhost:4567', { alpn: 'myproto' }); +const stream = await session.createBidirectionalStream(); + +// Tell the peer to stop sending with application error code 7. +stream.stopSending(7n); +``` + +See [Aborting a stream][] for an overview of all stream-abort APIs. + ### `stream.session` * `code` {number|bigint} The application error code to include in the @@ -2297,12 +2297,26 @@ const stream = await session.createBidirectionalStream(); stream.resetStream(42n); ``` +```cjs +const { connect } = require('node:quic'); + +async function main() { + const session = await connect('localhost:4567', { alpn: 'myproto' }); + const stream = await session.createBidirectionalStream(); + + // Abort the writable side with application error code 42. + stream.resetStream(42n); +} + +main(); +``` + See [Aborting a stream][] for an overview of all stream-abort APIs. ### `stream.stopSending([code])` * `code` {number|bigint} The application error code to include in the @@ -2330,6 +2344,20 @@ const stream = await session.createBidirectionalStream(); stream.stopSending(7n); ``` +```cjs +const { connect } = require('node:quic'); + +async function main() { + const session = await connect('localhost:4567', { alpn: 'myproto' }); + const stream = await session.createBidirectionalStream(); + + // Tell the peer to stop sending with application error code 7. + stream.stopSending(7n); +} + +main(); +``` + See [Aborting a stream][] for an overview of all stream-abort APIs. ### `stream.session`