From bcb9cf933789324f663aeed2e5e643a1e5d53a57 Mon Sep 17 00:00:00 2001 From: Tobi Akinyemi Date: Fri, 13 Mar 2026 02:44:29 +0000 Subject: [PATCH] fix: explicitly exit process on successful command completion On success, onEnd() relied on the Node.js event loop draining naturally to exit the process. This fails when stdio pipes are closed by the parent (e.g. CI runners, editor integrations, or tools that spawn the CLI with piped output and then close the connection). On Windows in particular, the orphaned process never exits and continuously leaks OS handles, eventually exhausting the kernel nonpaged pool and freezing the system. The fix: - Add exit() call in onEnd() for the success path (error path already had exit(1)) - Await onEnd() in bin/run.js so telemetry completes before exit Fixes #8031 --- bin/run.js | 4 ++-- src/commands/base-command.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/run.js b/bin/run.js index 028bdbc7adf..66ff6cd001c 100755 --- a/bin/run.js +++ b/bin/run.js @@ -54,9 +54,9 @@ Run ${chalk.inverse.hex(NETLIFY_CYAN_HEX)('{updateCommand}')} to update` try { await runProgram(program, argv) - program.onEnd() + await program.onEnd() } catch (error) { - program.onEnd(error) + await program.onEnd(error) } } diff --git a/src/commands/base-command.ts b/src/commands/base-command.ts index d710b892c96..5a96f027f08 100644 --- a/src/commands/base-command.ts +++ b/src/commands/base-command.ts @@ -437,6 +437,8 @@ export default class BaseCommand extends Command { logError(error_ instanceof Error ? error_ : format(error_)) exit(1) } + + exit() } async authenticate(tokenFromFlag?: string) {