Skip to content

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

Closed
melvincarvalho wants to merge 1 commit into
issue-56-programmatic-apifrom
issue-62-shutdown-output-race
Closed

fix(shutdown): stop Ctrl+C output racing the shell prompt#63
melvincarvalho wants to merge 1 commit into
issue-56-programmatic-apifrom
issue-62-shutdown-output-race

Conversation

@melvincarvalho
Copy link
Copy Markdown
Contributor

Closes #62. Stacked on #57 (issue-56-programmatic-api) — base it there, not gh-pages, because #57 introduces the handle.stop() shutdown path this fix builds on. Merge #57 first, then this retargets to gh-pages automatically.

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 now 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). Considered and rejected detached: true: it fixes ordering but orphans the server on terminal close / parent crash, leaving the port held.

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 printing the farewell on a fixed 1s timer,
which raced the returning shell prompt.

Drop the parent's redundant line and wait for the child's real 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 force-pushed the issue-62-shutdown-output-race branch from 23eaaf6 to 86d51a8 Compare May 25, 2026 18:45
@melvincarvalho melvincarvalho deleted the issue-62-shutdown-output-race branch May 25, 2026 19:47
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.

1 participant