method
quic.QuicStream.destroy
Immediately and abruptly destroys the stream. If error is provided and stream.onerror is set, the onerror callback is invoked before destruction. The stream.closed promise rejects with the error.
When the stream is destroyed with an error (or with an explicit options.code), the QUIC stack signals the abort to the peer:
- If the writable side is still open, a
RESET_STREAMframe is sent. - If the readable side is still open (a bidirectional stream, or a remote-initiated unidirectional stream), a
STOP_SENDINGframe is sent.
Both frames carry the same wire code, resolved with the following precedence:
options.code, when explicitly provided.- [
error.errorCode][], whenerroris a [QuicError][]. - The negotiated application protocol's "internal error" code (
H3_INTERNAL_ERROR(0x102) for HTTP/3, or the QUIC transport-layerINTERNAL_ERROR(0x1) for raw QUIC).
A clean destroy — no error and no options.code — does not emit RESET_STREAM or STOP_SENDING; the stream's existing close machinery handles teardown.
See Aborting a stream for an overview of the available stream-abort APIs.
Referenced types
interface StreamDestroyOptions
- code?: number | bigint
The application error code to include in the
RESET_STREAMandSTOP_SENDINGframes sent to the peer. Numbers are coerced toBigInt. When omitted, the wire code is derived fromerror(see below). - reason?: string
An optional human-readable reason string. Accepted for symmetry with
session.close()andsession.destroy(), but not transmitted on the wire — neitherRESET_STREAMnorSTOP_SENDINGcarry a reason field. Provided for application logging and for use by thestream.onerrorcallback.