Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions doc/api/quic.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])`

<!-- YAML
added: REPLACEME
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to have already been released, I am not sure when though

-->

* `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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Care to add a matching cjs code block?

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])`

<!-- YAML
added: REPLACEME
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to have been released already in 26.2.0: 7e6b77b

Might be getting the wrong commit though, worth validating with @jasnell

-->

* `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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

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`

<!-- YAML
Expand Down Expand Up @@ -4447,6 +4513,8 @@ throughput issues caused by flow control.
[`sessionOptions.sni`]: #sessionoptionssni-server-only
[`sessionOptions.token`]: #sessionoptionstoken-client-only
[`stream.destroy()`]: #streamdestroyerror-options
[`stream.resetStream()`]: #streamresetstreamcode
[`stream.stopSending()`]: #streamstopsendingcode
[`stream.headers`]: #streamheaders
[`stream.onerror`]: #streamonerror
[`stream.onwanttrailers`]: #streamonwanttrailers
Expand Down
Loading