-
Notifications
You must be signed in to change notification settings - Fork 388
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
[Feat]: Better DX for Abort events #1753
Comments
Update: After some digging I found out that we can listen to the close event on nativeEvent for this. import { getRequestEvent } from "solid-js/web";
export async function GET() {
const event = getRequestEvent()!;
event.nativeEvent.node.req.addListener('close', () => {
console.log('Client closed connection');
})
await new Promise(resolve => setTimeout(resolve, 5000));
return new Response(`I'm alive!`, {
status: 200,
});
} Nevertheless it would be good if |
Thanks for this issue and the thorough explanation, @tri2820 If you have time, it would be great if you could add a reproduction to our You can start the PR with the failing test and then we can have a clear path moving forward. Meanwhile, this workaround is worthy of the docs, so I'm pinging @LadyBluenotes in case she wants to create an issue there too :) As soon as I can get my hands on trying the workaround, I can help writing the guide (but you're also ofc welcomed to do so if you want) |
@tri2820 Thank you for bringing this up. I also think that having a better DX around The first question coming to my mind is if A similar question was asked in the Nitro Discussions under nitrojs/nitro#1541 but is unanswered 🙈. |
Duplicates
Latest version
Current behavior 😯
When the request is aborted, the abort event is not fired within server API route.
Example server API route
Example browser triggers
Expected behavior 🤔
When user cancel the request in browser, the abort event should be fired.
Steps to reproduce 🕹
Steps:
Context 🔦
I'm building an AI chat app that streams the token from the AI provider back to the user.
Currently when the user clicks aborting the request, the api route could not detect that and keep streaming from the AI provider, wasting token.
Not sure if related but Next.js used to have a similar issue vercel/next.js#48682
Your environment 🌎
The text was updated successfully, but these errors were encountered: