Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs(main): describe what runs before listen() binds the port
Yudhi Armyndharis99c5ce0f0a67
diff --git a/src/main.ts b/src/main.tsindex 28bcd0335..c520ad02d 100644--- a/src/main.ts+++ b/src/main.ts@@ -240,11 +240,13 @@ async function bootstrap() {}// A failed bootstrap MUST terminate the process with a non-zero code, not just set `process.exitCode`:-// listen() runs the FULL init (sessions, Redis, pg, Chromium) before binding the port, so a bind failure-// (EADDRINUSE) would otherwise leave a zombie process — no HTTP port, yet still holding the event loop-// open and running WhatsApp sessions, invisible to Docker's restart policy. runBootstrapOrExit logs the-// failure, runs a bounded best-effort app.close() teardown, then exits(1); a successful boot returns-// without touching exit. Puppeteer's own `exit` handlers kill any browser children still up.+// listen() runs the full module init (database, Redis, plugin registration) before binding the port, and+// the detached session auto-start (SessionService.onApplicationBootstrap) is already launching engines by+// then, so a bind failure (EADDRINUSE) would otherwise leave a zombie process: no HTTP port, yet still+// holding the event loop open and running WhatsApp sessions, invisible to Docker's restart policy.+// runBootstrapOrExit logs the failure, runs a bounded best-effort app.close() teardown, then exits(1); a+// successful boot returns without touching exit. Puppeteer's own `exit` handlers kill any browser+// children still up.void runBootstrapOrExit(bootstrap, {logger: createLogger('Bootstrap'),closeApp: () => (appInstance ? appInstance.close() : Promise.resolve()),