From d7df050860f7540af9b1f15df77f90c7961ad2f0 Mon Sep 17 00:00:00 2001 From: Ashen <310210685+ashen0x@users.noreply.github.com> Date: Wed, 19 Aug 2026 02:48:00 +0530 Subject: [PATCH] fix(daemon): exit when the HTTP server fails to start (#79) --- src/daemon/index.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/daemon/index.ts b/src/daemon/index.ts index 56b8110..7281250 100644 --- a/src/daemon/index.ts +++ b/src/daemon/index.ts @@ -355,6 +355,17 @@ async function main(): Promise { }); }; + // Without this a listen failure only reaches uncaughtException, which logs and + // returns, leaving the daemon alive holding the wallet locks with no listener. + server.on("error", (error) => { + logger.error("Failed to start Routstr daemon:", error); + console.error( + "Failed to start Routstr daemon:", + error instanceof Error ? error.message : error, + ); + process.exit(1); + }); + startupProgress("Starting HTTP server..."); server.listen(port, host, async () => { logger.log(`Routstr daemon listening on http://${host}:${port}/v1`);