method

quic.QuicStream.destroy

error?: any,
): void;

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_STREAM frame is sent.
  • If the readable side is still open (a bidirectional stream, or a remote-initiated unidirectional stream), a STOP_SENDING frame is sent.

Both frames carry the same wire code, resolved with the following precedence:

  1. options.code, when explicitly provided.
  2. [error.errorCode][], when error is a [QuicError][].
  3. The negotiated application protocol's "internal error" code (H3_INTERNAL_ERROR (0x102) for HTTP/3, or the QUIC transport-layer INTERNAL_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_STREAM and STOP_SENDING frames sent to the peer. Numbers are coerced to BigInt. When omitted, the wire code is derived from error (see below).

  • reason?: string

    An optional human-readable reason string. Accepted for symmetry with session.close() and session.destroy(), but not transmitted on the wire — neither RESET_STREAM nor STOP_SENDING carry a reason field. Provided for application logging and for use by the stream.onerror callback.