- Introduction
- Quick start
- Philosophy
- Comparison
- Default behaviors
- Limitations
- Debugging runbook
- FAQ
- Mocking HTTP
- Mocking SSE
- Mocking GraphQL
- Mocking WebSocket
- Integrations
- API
- CLI
- Best practices
- Recipes
Closing the connection
Mocking SSE connection closure.
You can close the intercepted client connection by calling client.close() at any time in your request handler.
sse('/stream', ({ client }) => {
client.close()
})Unlike client.error(), calling client.close() produces a graceful connection closure and will not emit the error event on the underlying EventSource instance.