method

quic.QuicSession.close

): Promise<void>;

Initiate a graceful close of the session. Existing streams will be allowed to complete but no new streams will be opened. Once all streams have closed, the session will be destroyed. The returned promise will be fulfilled once the session has been destroyed. If a non-zero code is specified, the promise will reject with an ERR_QUIC_TRANSPORT_ERROR or ERR_QUIC_APPLICATION_ERROR depending on the type.

Referenced types

interface SessionDestroyOptions

  • code?: number | bigint

    The error code to include in the CONNECTION_CLOSE frame sent to the peer. Default: 0 (no error).

  • reason?: string

    An optional human-readable reason string included in the CONNECTION_CLOSE frame. Per RFC 9000, this is for diagnostic purposes only and should not be used for machine-readable error descriptions.

  • type?: 'transport' | 'application'

    Either 'transport' or 'application'. Determines the error code namespace used in the CONNECTION_CLOSE frame. When 'transport' (the default), the frame type is 0x1c and the code is interpreted as a QUIC transport error. When 'application', the frame type is 0x1d and the code is application-specific. Default: 'transport'.