Skip to content

fix(shutdown): stop Ctrl+C output racing the shell prompt#64

Merged
melvincarvalho merged 1 commit into
gh-pagesfrom
issue-62-shutdown-order
May 25, 2026
Merged

fix(shutdown): stop Ctrl+C output racing the shell prompt#64
melvincarvalho merged 1 commit into
gh-pagesfrom
issue-62-shutdown-order

Conversation

@melvincarvalho
Copy link
Copy Markdown
Contributor

Closes #62. Clean re-do — single commit on top of gh-pages (which now carries #57's handle.stop() handler).

Problem

On a terminal Ctrl+C the JSS child shares the CLI's process group and receives SIGINT too. The child already prints Shutting down... and exits on its own. The CLI was also printing ⚠ Shutting down gracefully..., then racing the Goodbye 👋 farewell against the returning shell prompt — so the farewell could land after the prompt, with a duplicated "shutting down" line.

Fix

Drop the parent's redundant line. handle.stop() already awaits the child's exit, so the farewell prints only once the child is gone — ordered ahead of the prompt.

  Shutting down...      <- child
✓  Server stopped       <- parent, after child has exited
Goodbye! 👋
$                       <- prompt, last

Both processes stay in the same group, so closing the terminal still tears the server down (SIGHUP). detached: true was considered and rejected — it fixes ordering but orphans the server on terminal close, holding the port.

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
@melvincarvalho melvincarvalho merged commit dc2a9d2 into gh-pages May 25, 2026
@melvincarvalho melvincarvalho deleted the issue-62-shutdown-order branch May 25, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shutdown output races: "Goodbye" can print after the shell prompt returns on Ctrl+C

1 participant