关闭连接

模拟 SSE 连接关闭。

你可以在请求处理程序中的任何时候调用 client.close() 来关闭拦截的客户端连接。

¥You can close the intercepted client connection by calling client.close() at any time in your request handler.

sse('/stream', ({ client }) => {
  client.close()
})

client.error() 不同,调用 client.close() 会优雅地关闭连接,并且不会在底层 EventSource 实例上触发 error 事件。

¥Unlike client.error(), calling client.close() produces a graceful connection closure and will not emit the error event on the underlying EventSource instance.