fix(cli): catch unhandled promise rejections in self-contained CLIs (#203)

The freehire and linkedin CLIs called main().then(code => process.exit(code)) with no .catch(). If main() throws or returns a rejected promise, the .then() never runs, process.exit() is never called, and the runtime terminates with exit code 0 - a runtime failure becomes indistinguishable from success (and would suppress the Step 1c WebSearch fallback, which keys on non-zero exit). Adds a .catch() that writes the same JSON error shape the rest of each file already uses ({error, code: INTERNAL_ERROR} to stderr) and exits 1. Scoped to the two self-contained CLIs only; the bunli portals catch internally via defineCommand.

By @oscarbol09.
This commit is contained in:
Oscar Madera
2026-07-20 21:54:10 +02:00
committed by GitHub
parent a5de938492
commit 73fb71587c
2 changed files with 22 additions and 2 deletions
+11 -1
View File
@@ -139,4 +139,14 @@ async function main(): Promise<number> {
return 1
}
main().then((code) => process.exit(code))
main()
.then((code) => process.exit(code))
.catch((e) => {
process.stderr.write(
JSON.stringify({
error: e instanceof Error ? e.message : String(e),
code: "INTERNAL_ERROR",
}) + "\n",
)
process.exit(1)
})