mirror of
https://github.com/MadsLorentzen/ai-job-search.git
synced 2026-09-17 08:36:25 +00:00
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:
@@ -186,4 +186,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)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user