Needing some help, is there is no mechanism for handling the event that a client disconnects/cancels
Needing some help, is there is no mechanism for handling the event that a client disconnects/cancels a request?
When implementing event streams (SSE), I need to do some cleanup when the client disconnects from the stream.
Currently, one of two things happen:
(1) The request will just end with no opportunity to clean up.
(2) I do some complex
The only way is to regularly test writing to the stream (e.g. a SSE
When implementing event streams (SSE), I need to do some cleanup when the client disconnects from the stream.
Currently, one of two things happen:
(1) The request will just end with no opportunity to clean up.
(2) I do some complex
ctx.waitUntil() with a promise that manually resolves when the stream closes, and now I can do cleanup within that promise, but now I have no way to know that the client has disconnected and ctx.waitUntil() will just be aborted by the runtime 30s or so after the client disconnects.The only way is to regularly test writing to the stream (e.g. a SSE
: comment) to test if the client is alive so that I can cleanup before that 30s elapses... is that correct? Any way to know immediately when a client has disconnected?