diff --git a/lib/batch.js b/lib/batch.js index 49eae3f..d0dcb38 100644 --- a/lib/batch.js +++ b/lib/batch.js @@ -1,9 +1,10 @@ import createError from 'http-errors' +import onFinished from 'on-finished' export function batch({cluster}) { return async (req, res) => { const ac = new AbortController() - req.on('close', () => ac.abort()) + onFinished(res, () => ac.abort()) // Abort the batch request if the client disconnects const {requests} = req.body