Skip to content

fix(dev): stop the Rivet Engine when the terminal closes - #34

Merged
eersnington merged 1 commit into
mainfrom
fix/dev-sighup-engine
Nov 16, 2026
Merged

eersnington merged 1 commit into
mainfrom
fix/dev-sighup-engine

Conversation

@eersnington

Copy link
Copy Markdown
Member

Closing the terminal that runs orange dev left the local Rivet Engine running with PPID 1. The next orange dev reused it without a message. Ctrl-C and SIGTERM already stopped it.

A closed terminal stopped the Engine stop in three ways:

Cause Before Now
No SIGHUP handler in the CLI or the runtime Node exits at once and skips the Engine stop SIGHUP is a stop request in dev-session.ts and runner.ts
A hang-up sends SIGHUP twice (shell, then kernel) The second one counts as "force" and SIGKILLs the runtime SIGHUP only starts a stop. stop() in the runtime runs once and a second call waits for the Engine
A write to the closed terminal fails with EIO EIO crashes the CLI, or as a closed output it raises a second, forcing stop closed-output.ts handles EIO like EPIPE, and a closed output only starts a stop
  • process-protocol.ts adds "SIGHUP" as a stop reason.
  • tests/orange-dev.ts can run orange dev on a real pty (script(1)) and hang it up.
  • An Engine whose runtime is SIGKILLed still keeps running. That needs a watcher in the Engine and is not in this change.

Closing the terminal sends SIGHUP to orange dev and its runtime. Node's default
exits at once, so the Engine, in its own process group, kept running and the
next orange dev reused it. Treat SIGHUP as a stop request in both processes.
A repeated SIGHUP or an EIO write to the closed terminal only starts a stop,
so it can no longer force-kill the runtime before it stops the Engine.
@eersnington
eersnington force-pushed the fix/dev-sighup-engine branch from 6fca89e to 20c6421 Compare November 14, 2026 21:54
@eersnington
eersnington merged commit ca596fa into main Nov 16, 2026
10 checks passed
@eersnington
eersnington deleted the fix/dev-sighup-engine branch November 16, 2026 19:45
@github-actions

Copy link
Copy Markdown

Preview removed; R2 assets deleted.

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