session.close([options])


  • options <Object>
    • code <bigint> | <number> 要包含在发送给对等方的 CONNECTION_CLOSE 帧中的错误代码。默认值: 0(无错误)。
    • type <string> 要么是 'transport' 要么是 'application'。确定在 CONNECTION_CLOSE 帧中使用的错误代码命名空间。当为 'transport'(默认值)时,帧类型为 0x1c,并且代码被解释为 QUIC 传输错误。当为 'application' 时,帧类型为 0x1d,代码是应用特定的。默认值: 'transport'
    • reason <string>CONNECTION_CLOSE 帧中可选择包含的人类可读原因字符串。根据 RFC 9000,这仅用于诊断目的,不应用于机器可读的错误描述。
  • 返回:<Promise>

启动会话的优雅关闭。现有的数据流将被允许完成,但不会打开新的数据流。一旦所有数据流关闭,会话将被销毁。返回的 promise 将在会话被销毁后完成。如果指定了非零的 code,promise 将根据 type 拒绝,并返回 ERR_QUIC_TRANSPORT_ERRORERR_QUIC_APPLICATION_ERROR

🌐 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.