Skip to content

Commit dc2a9d2

Browse files
fix(shutdown): stop Ctrl+C output racing the shell prompt (#64)
The JSS child shares the CLI's process group, so a terminal Ctrl+C delivers SIGINT to both. The child already prints "Shutting down..." and exits on its own; the CLI was also printing "Shutting down gracefully..." and then racing the farewell against the returning shell prompt. Drop the parent's redundant line and let handle.stop() await the child's exit before the farewell, so output stays ordered. Same process group, so closing the terminal still tears the server down (no detached orphan). Closes #62
1 parent 5b4748c commit dc2a9d2

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,12 +519,15 @@ handle.exit.then(({ code, signal }) => {
519519
}
520520
});
521521

522-
// Graceful shutdown
522+
// Graceful shutdown. The JSS child shares our process group, so a terminal
523+
// Ctrl+C delivers SIGINT to it too — it prints its own "Shutting down..."
524+
// and exits. We don't duplicate that line; we just await its exit (which
525+
// handle.stop() does) and then print the farewell, so the output stays
526+
// ordered ahead of the returning shell prompt instead of racing it.
523527
process.on('SIGINT', async () => {
524-
console.log('\n' + chalk.yellow('⚠ Shutting down gracefully...'));
525528
await handle.stop();
526-
console.log(chalk.green('✓ Server stopped'));
527-
console.log(chalk.dim('\nGoodbye! 👋\n'));
529+
console.log(chalk.green('\n✓ Server stopped'));
530+
console.log(chalk.dim('Goodbye! 👋\n'));
528531
process.exit(0);
529532
});
530533

0 commit comments

Comments
 (0)