Gitpulse
LatestReleasesStand-up
Merged
Size
L
Large: 500-1000 weighted lines
Change Breakdown
Feature85%
Refactor15%
#3191feat(cli): auto-cancel dev runs on CLI exit via detached watchdog

In-flight dev runs instantly canceled on CLI exit

In-flight dev runs instantly canceled on CLI exit
ER
ericallam
·Mar 9, 2026·#3191feat(cli): auto-cancel dev runs on CLI exit via detached watchdog

A new background monitor terminates in-flight cloud executions when local environments are shut down, preventing zombie runs from lingering.

Local dev servers can now be shut down without leaving ghost runs hanging in the cloud. Previously, aborting a local session could leave active executions stuck waiting on a heartbeat timeout for up to five minutes.

In-flight runs are now instantly canceled when the dev CLI shuts down. An invisible background monitor is spawned to watch the main process. If the CLI exits abruptly—like during a forced termination—this monitor immediately notifies the platform to terminate active jobs.

Active run IDs are written to a local file and tracked by a . When a crash or forced exit is detected, a is called to finalize the runs. If there are more than 25 active tasks, the cancellation is delegated to a background queue.

View Original GitHub Description

When the dev CLI exits (e.g. ctrl+c via pnpm), runs that were mid-execution previously stayed stuck in EXECUTING status for up to 5 minutes until the heartbeat timeout fired. Now they are cancelled within seconds.

The dev CLI spawns a lightweight detached watchdog process at startup. The watchdog monitors the CLI process ID and, when it detects the CLI has exited, calls a new POST /engine/v1/dev/disconnect endpoint to cancel all in-flight runs immediately (skipping PENDING_CANCEL since the worker is known to be dead).

Watchdog design:

  • Fully detached (detached: true, stdio: ignore, unref()) so it survives even when pnpm sends SIGKILL to the process tree
  • Active run IDs maintained via atomic file write (.trigger/active-runs.json)
  • Single-instance guarantee via PID file (.trigger/watchdog.pid)
  • Safety timeout: exits after 24 hours to prevent zombie processes
  • On clean shutdown, the watchdog is killed (no disconnect needed)

Disconnect endpoint:

  • Rate-limited: 5 calls/min per environment
  • Capped at 500 runs per call
  • Small counts (<= 25): cancelled inline with pMap concurrency 10
  • Large counts: delegated to the bulk action system
  • Uses finalizeRun: true to skip PENDING_CANCEL and go straight to FINISHED

Run engine change:

  • cancelRun() now respects finalizeRun when the run is in EXECUTING status, skipping the PENDING_CANCEL waiting state and going directly to FINISHED
© 2026 · via Gitpulse