From ef867f3e28d64f6cccbfac2cf94054bd241c0df2 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 30 Sep 2026 21:19:42 +0200 Subject: [PATCH] Watchdog notice reader: start the verb after the module finishes initialising The top-level await ran main() before the const declarations below it, so every process run died in the temporal dead zone with unexpected-error. Co-Authored-By: Claude Sonnet 5.5 --- tools/watchdog-notice.mjs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/watchdog-notice.mjs b/tools/watchdog-notice.mjs index 18fa6a7..df773c6 100644 --- a/tools/watchdog-notice.mjs +++ b/tools/watchdog-notice.mjs @@ -36,13 +36,6 @@ const SUBJECT = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/; class NoticeError extends Error {} const fail = (code) => new NoticeError(code); -try { - process.exitCode = await main(process.argv.slice(2)); -} catch (error) { - process.stderr.write(`watchdog-notice: ${error instanceof NoticeError ? error.message : "unexpected-error"}\n`); - process.exitCode = 1; -} - async function main(args) { const [verb, ...rest] = args; const options = parseArgs(rest); @@ -282,3 +275,10 @@ function requireOption(options, name) { if (!options[name]) throw fail(`missing-option-${name}`); return options[name]; } + +try { + process.exitCode = await main(process.argv.slice(2)); +} catch (error) { + process.stderr.write(`watchdog-notice: ${error instanceof NoticeError ? error.message : "unexpected-error"}\n`); + process.exitCode = 1; +}