From 9e024f406bb0b690bfa27c2ddbd457588c13c800 Mon Sep 17 00:00:00 2001 From: Alexander Clouter Date: Mon, 4 Aug 2025 19:42:19 +0100 Subject: [PATCH] fix: response.write() to return a bool (resolves #683) Returning 'false'y tells the sender they need to wait for the 'drain' event which can cause middleware to hang (eg. SvelteKit adapter-node and trpc) Original fix from @KATT in https://github.com/KATT/serverless-express/commit/9ba260ec7148d81a7caf2db84e62a1ba38b61925 --- src/response.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/response.js b/src/response.js index a65e0208..9d8df958 100644 --- a/src/response.js +++ b/src/response.js @@ -125,6 +125,11 @@ module.exports = class ServerlessResponse extends http.ServerResponse { if (typeof cb === 'function') { cb() } + + // must return bool to indicate if the data was flushed to the + // kernel and if not then indicate that the sender must wait + // for drain event; which we never do so always return true. + return true; } }) }