Hi there! Is there any way to catch request cancellation? Eg. I'm using a stream as response and despite if a request is canceled stream continues to push data to response what causes an error.
Eg.
app.use(async (ctx) => {
const stream = JSONStream();
stream.on('error', ctx.onerror);
ctx.body = stream;
const qs = new QueryStream('select * from users');
db
.stream(qs, s => {
s.on('error', ctx.onerror);
s.pipe(stream);
})
});
If anyone is intereseted, you have to use close event on node req
ctx.req.on('close', () => {
// your logic here...
});
Most helpful comment
If anyone is intereseted, you have to use
closeevent on nodereq