From 04d5ea50838acf748bfd0dbd750aff7dde3c7017 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Desboeufs?= Date: Fri, 13 Sep 2024 00:48:32 +0200 Subject: [PATCH] Fix aborting --- lib/batch.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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