连接错误
模拟 SSE 连接错误。
你可以通过在请求处理程序中调用 client.error() 来使拦截到的客户端连接出错:
¥You can error the intercepted client connection by calling client.error() in your request handler:
sse('/stream', ({ client }) => {
client.error()
})客户端连接错误不接受闭包原因。
¥Client connection errors do not accept the closure reason.
与 client.close() 不同,调用 client.error() 会中止连接,这将在底层 EventSource 实例上分发 error 事件。
¥Unlike client.close(), calling client.error() aborts the connection, which will dispatch the error event on the underlying EventSource instance.