From 8503b41d514484907cb687abd1b1441a302b2cd7 Mon Sep 17 00:00:00 2001 From: nocode Date: Wed, 23 Sep 2026 22:04:10 +0200 Subject: [PATCH] fix(web): say out loud when the dashboard cannot listen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A failed `listen` only produced a generic line the bot then carried on past, so the site was simply absent with nothing explaining why — and inside a container a bind on an unpublished port succeeds while staying unreachable, which looks identical to a crash from the browser. The error now names the address, the port and the actual cause, and a successful bind on `0.0.0.0` reminds that the port still has to be published by the host. Co-Authored-By: Claude Opus 5 (1M context) --- src/web/server.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/web/server.js b/src/web/server.js index 9dd2a00..ab5375e 100644 --- a/src/web/server.js +++ b/src/web/server.js @@ -143,8 +143,32 @@ export function startWebServer({ client = null, setupOnly = false } = {}) { server.listen(env.web.port, env.web.host, () => { const url = env.web.publicUrl || `http://${env.web.host}:${env.web.port}`; log.info(`Dashboard listening on ${env.web.host}:${env.web.port}`, { url, setupOnly }); + + // Inside a container, binding a port that is not published succeeds and is + // still unreachable from outside, which looks exactly like a crash from the + // browser. Say it once, here, where the port is known. + if (env.web.host === '0.0.0.0') { + log.info( + `Le tableau de bord écoute sur le port ${env.web.port}. Dans un conteneur ou sur un panel, ` + + 'ce port doit aussi faire partie des allocations publiées, sinon il reste injoignable de l’extérieur.', + ); + } + }); + + server.on('error', (error) => { + const causes = { + EADDRINUSE: `le port ${env.web.port} est déjà pris par un autre processus`, + EACCES: `le port ${env.web.port} est interdit à ce processus (port privilégié, ou restreint par l’hôte)`, + EADDRNOTAVAIL: `l’adresse ${env.web.host} n’existe pas sur cette machine`, + }; + const cause = causes[error.code] ?? error.message; + + log.error( + `Le tableau de bord n'a pas pu démarrer sur ${env.web.host}:${env.web.port} — ${cause}. ` + + 'Le bot continue sans le site : corrige `WEB_HOST` ou `WEB_PORT`, puis redémarre.', + error, + ); }); - server.on('error', (error) => log.error('Dashboard server error', error)); // Open event streams would otherwise keep the server from closing. server.on('close', closeEventStreams); return server;