From 698798f1417b8e8d9d5d086b1f1d2f88c398237c Mon Sep 17 00:00:00 2001 From: David Moore Date: Fri, 26 Apr 2024 16:47:40 +1000 Subject: [PATCH] fix: close the node app when http proxy stream ends --- src/resources/http.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/resources/http.ts b/src/resources/http.ts index e890f39..eaaff63 100644 --- a/src/resources/http.ts +++ b/src/resources/http.ts @@ -80,6 +80,14 @@ const createWorker = async ( srv.on('close', () => { httpProxyStream.cancel(); }); + + httpProxyStream.on('end', () => { + if (typeof srv.close === 'function') { + srv.close(); + } else { + process.exit(1); // Close the Node.js application with a non-zero exit code + } + }); } };