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`);