From 73fb71587c4243327346e7070a669ff99b0ab01d Mon Sep 17 00:00:00 2001 From: Oscar Madera <80536682+oscarbol09@users.noreply.github.com> Date: Mon, 20 Jul 2026 14:54:10 -0500 Subject: [PATCH] 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. --- .agents/skills/freehire-search/cli/src/cli.ts | 12 +++++++++++- .agents/skills/linkedin-search/cli/src/cli.ts | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.agents/skills/freehire-search/cli/src/cli.ts b/.agents/skills/freehire-search/cli/src/cli.ts index e89794a..0faba25 100644 --- a/.agents/skills/freehire-search/cli/src/cli.ts +++ b/.agents/skills/freehire-search/cli/src/cli.ts @@ -186,4 +186,14 @@ async function main(): Promise { 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) + }) diff --git a/.agents/skills/linkedin-search/cli/src/cli.ts b/.agents/skills/linkedin-search/cli/src/cli.ts index 6e13fa5..3f68c07 100644 --- a/.agents/skills/linkedin-search/cli/src/cli.ts +++ b/.agents/skills/linkedin-search/cli/src/cli.ts @@ -139,4 +139,14 @@ async function main(): Promise { 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) + })