From be2bf09b8ea3a90e1936059cefa7626fdd67b494 Mon Sep 17 00:00:00 2001 From: David Moore <4121492+davemooreuws@users.noreply.github.com> Date: Fri, 26 Apr 2024 17:15:25 +1000 Subject: [PATCH] fix: close the node app when http proxy stream ends (#226) --- 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 + } + }); } };