In my frontend code I’m using abortcontroller in the signal in fetch. I’m listening to client disconnection in my NodeJs backend with this
req.connection.on("close", () => {
logger.info("Client disconnected")
abortController.abort()
})
Its working Locally but the client disconnection is only triggered after API finished on GCR. This API is set up with SSE and getting instant disconnection and abort is crucial.
res.setHeader("Content-Type", "text/event-stream")
res.setHeader("Cache-Control", "no-cache")
res.setHeader("Connection", "keep-alive")
What am I doing wrong or is there anything missing
I want to trigger abort in the backend when frontend client disconnects
Vaibhav Prakash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.