Skip to content

Commit 9001ae5

Browse files
committed
fix: improve bootstrap error handling
Improve error handling in bootstrap processes to suppress spurious errors and handle process exit codes more robustly: Bootstrap-smol improvements: - Suppress spurious "command failed" errors during CLI execution - Extract error message once for reuse - Only write actual errors to stderr Node bootstrap improvements: - Handle signal-based process exits correctly - Exit with code 1 when child process terminated by signal - Exit with child's exit code otherwise (or 0 if none) These changes reduce noise in error output and ensure correct exit codes are propagated through the bootstrap chain.
1 parent cef8612 commit 9001ae5

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

packages/bootstrap/src/bootstrap-smol.mts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ async function main() {
1919

2020
// Run the bootstrap.
2121
main().catch((e) => {
22+
// Suppress spurious "command failed" error from process.exit() during CLI execution.
23+
const errorMsg = e instanceof Error ? e.message : String(e)
24+
if (errorMsg.includes('command failed')) {
25+
return
26+
}
2227
// Use process.stderr.write() directly to avoid console access during early bootstrap.
23-
process.stderr.write(`Bootstrap error: ${e instanceof Error ? e.message : String(e)}\n`)
28+
process.stderr.write(`Bootstrap error: ${errorMsg}\n`)
2429
process.exit(1)
2530
})

packages/cli/src/bootstrap/node.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ async function main(): Promise<void> {
146146
process.exit(1)
147147
})
148148

149-
child.on('exit', code => {
149+
child.on('exit', (code, signal) => {
150150
// eslint-disable-next-line n/no-process-exit
151-
process.exit(code ?? 0)
151+
process.exit(code ?? (signal ? 1 : 0))
152152
})
153153
}
154154

0 commit comments

Comments
 (0)