-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Canceled Response #11751
Comments
If |
Perhaps this will be useful for debugging: The request object's signal is not aborted after closing the connection.
|
With node-adapter this gets even worse, I am not able to kill the server with the |
I was able to pin down the issue in my case. I was using port forwarding from a container and accessing the SSE API through the forwarded port. In this case the client side closure doesn't trigger the closure on the server side. However, if I |
A quick update, the I'm starting to think it's an upstream issue with Bun itself, since I don't see any Kit changes referenced in this issue regarding this |
I've tested this and it does indeed cancel after a few seconds of disconnection (refreshing the page, navigating away from the page, etc.). I'll close this issue for now |
Describe the bug
When dealing with streams or large amount of data in general, I need a way to detect when a client has disconnected, otherwise I'll be wasting I/O time on emitting data to a stream that nobody's ever going to read.
Here's an example
That readable stream will continue to enqueue data until it's done, even if the client has aborted the connection (e.g. closed the tab).
From our side, in user-land, there's currently no way to detect when a client has disconnected, and it looks like the cancel event on the readable stream is also not triggered, so this also doesn't work:
Reproduction
https://github.com/tncrazvan/sveltekit-canceled-response-issue-reproduction
Run with
npm run dev
Open the website in your browser
![image](https://private-user-images.githubusercontent.com/6891346/300237090-bcc33ce1-fac6-4382-b4a7-be7966759f14.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NTE5MTQsIm5iZiI6MTczODk1MTYxNCwicGF0aCI6Ii82ODkxMzQ2LzMwMDIzNzA5MC1iY2MzM2NlMS1mYWM2LTQzODItYjRhNy1iZTc5NjY3NTlmMTQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDdUMTgwNjU0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MGVhODJhZjgwN2Y5YWM2ZjRlOTY4ODAzMDg4ZWNhMDFhN2RmODg4YjBiMDY4ZjhiMTIzNThkNmIxYjE1ZTA2MCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.MR8d6WbhWIh5UPgMNY_nepJYjRDLV4c-rDoAUUKL-Sw)
At this point you should see a bunch of string chunks logging in your console, that means the website is downloading the data
Something like this
Close the tab to abruptly cancel the connection
Take a look back at your console, it's still emitting data to a closed connection because the
cancel
event did not triggerThe server should invoke
cancel
on the stream and trigger this part https://github.com/tncrazvan/sveltekit-canceled-response-issue-reproduction/blob/7bb48bf507273af48db78e7cbe4e5826de53cdc7/src/routes/test/%2Bserver.js#L39Logs
No response
System Info
Severity
blocking an upgrade
Additional Information
When the content of the response is indeed a ReadableStream and the client aborts the http connection, sveltekit should invoke the
cancel
method on the stream.If you point me into the right direction, I'm happy to give it a shot a fixing this myself, I just need some general indications.
The text was updated successfully, but these errors were encountered: