-
Notifications
You must be signed in to change notification settings - Fork 178
fix: Add automatic response cleanup via AbortSignal #952
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
fix: Add automatic response cleanup via AbortSignal #952
Conversation
changeset changeset
🦋 Changeset detectedLatest commit: 7d0cb12 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the other one in cloudflare for the same thing makes me think that we should use a single interface in aws.
What make the most sense IMO is probably to add an AbortSignal in the StreamCreator. When it aborts, we just destroy the stream.
It's basically what you did, but using AbortSignal instead of our own implementation
Thanks for the review Nico! This was an excellent idea. I am now using an Update: Instead we pass the original |
|
Thanks for the review Kheuzy! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks!!!
To make
request.signal.onabortwork in route handlers. Currently only works forcloudflare-node,nodeandexpress-dev. It will close theOpenNextNodeResponsewe pass intoNextServer's request handler when the original response in the wrapper is closed. This will ensure that the AbortSignal associated withrequest.signalis properly triggered when a client disconnects during a streaming response.I did try to get it to work with
awsLambda.streamifyResponse. It looks like we get no event emitted onresponseStreamwhen a client disconnects. I even tried with a barebone Lambda like this: