Next.js Discord

Discord Forum

Is there any way to listen to disconnect event with next app directory in api route ?

Unanswered
Blue whiting posted this in #help-forum
Open in Discord
Blue whitingOP
I am looking for implementing a stop generate button to a LLM app similar to ChatGPT. I am not using vercel ai sdk, so implemented SSE from scratch. is there any way i can stop the stream generation from routes.ts file ?

1 Reply

I don't sure how you implement the architecture, but route handlers are not long-running processes.

Generally, if you want to stop the execution of a route from another route, it's possible. Since everything is happening in the same server, you can use a map or queue to communicate between routes