diff --git a/assist/utils/httpHandlers.js b/assist/utils/httpHandlers.js index c6514e2dc..500e4fdb5 100644 --- a/assist/utils/httpHandlers.js +++ b/assist/utils/httpHandlers.js @@ -27,9 +27,14 @@ const respond = function (req, res, data) { res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify(result)); } else { - res.cork(() => { - res.writeStatus('200 OK').writeHeader('Content-Type', 'application/json').end(JSON.stringify(result)); - }); + if (!res.aborted) { + res.cork(() => { + res.writeStatus('200 OK').writeHeader('Content-Type', 'application/json').end(JSON.stringify(result)); + }); + } else { + logger.debug("response aborted"); + return; + } } const duration = performance.now() - req.startTs; IncreaseTotalRequests(); diff --git a/ee/assist/server.js b/ee/assist/server.js index 123501634..2a6ec5bee 100644 --- a/ee/assist/server.js +++ b/ee/assist/server.js @@ -83,9 +83,11 @@ if (process.env.uws !== "true") { const uWrapper = function (fn) { return (res, req) => { res.id = 1; + res.aborted = false; req.startTs = performance.now(); // track request's start timestamp req.method = req.getMethod(); res.onAborted(() => { + res.aborted = true; onAbortedOrFinishedResponse(res); }); return fn(req, res); diff --git a/ee/assist/utils/wsServer.js b/ee/assist/utils/wsServer.js index 0eaf37abd..98e0059a8 100644 --- a/ee/assist/utils/wsServer.js +++ b/ee/assist/utils/wsServer.js @@ -62,7 +62,9 @@ const doFetchAllSockets = async function () { } } try { - return await io.fetchSockets(); + let result = await io.fetchSockets(); + lastKnownResult = result; + return result; } catch (error) { logger.error('Error fetching sockets:', error); return lastKnownResult;