Skip to content

fix(cli): stop global vp dev on SIGTERM - #3521

Closed
fengmk2 wants to merge 1 commit into
codex/issue-3106-local-dev-signalfrom
issue-3106-global-dev-signal
Closed

fengmk2 wants to merge 1 commit into
codex/issue-3106-local-dev-signalfrom
issue-3106-global-dev-signal

Conversation

@fengmk2

@fengmk2 fengmk2 commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

On Unix, global vp dev runs three processes: the Rust vp, node dist/bin.js from the project's vite-plus, and Vite. A SIGTERM or SIGHUP to the vp process ID stopped only vp. dist/bin.js and Vite kept running, and Vite kept the port open. #3512 does not change this path, because dist/bin.js keeps Vite as a child process when the global CLI starts it.

execute_with_terminal_guard now forwards SIGTERM and SIGHUP to its child while the child runs. The global CLI and dist/bin.js both use this function, so a signal to the vp process ID passes through dist/bin.js to Vite. vp then exits with Vite's exit code (143 for SIGTERM).

  • SIGINT is still not forwarded. The terminal sends Ctrl+C to the whole process group, so a forwarded copy would reach the child a second time.
  • A signal that the caller ignores, such as SIGHUP under nohup, stays ignored.

The global CLI uses this function for every command that it delegates to dist/bin.js. Inside dist/bin.js, only vp dev and vp preview use it. Other commands, such as vp build, still stop only dist/bin.js and leave their child running. Project-local vp preview, and project-local vp dev when it keeps Vite as a child process (in a Worker or with an IPC channel), now also stop on these signals.

Stacked on #3512. Refs #3106.

🤖 Generated with Claude Code

Global `vp dev` runs the Rust `vp`, `node dist/bin.js`, and Vite. A
SIGTERM to the `vp` process ID stopped only `vp`, and Vite kept the
port open.

`execute_with_terminal_guard` now forwards SIGTERM and SIGHUP to the
child while the child runs. Both wrappers use this function, so the
signal passes through `dist/bin.js` to Vite. SIGINT is still not
forwarded, because the terminal sends Ctrl+C to the whole process
group. A signal that the caller ignores stays ignored.

Refs #3106.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fengmk2
fengmk2 added this pull request to stack #3522 November 21, 2026 06:14
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://issue-3106-global-dev-signal-viteplus-dev.voidzero-docs.workers.dev (commit 8622c23)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://34f965df-viteplus-dev.voidzero-docs.workers.dev 8622c23 2026-11-21T06:15:22.125Z Visit the dashboard ↗

@fengmk2
fengmk2 marked this pull request as draft November 21, 2026 06:15
@fengmk2 fengmk2 changed the title fix(cli): forward SIGTERM and SIGHUP from vp wrappers to the child fix(cli): stop global vp dev on SIGTERM Nov 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

CLI artifact sizes (8622c23)

Final release artifacts built by the canonical build-upstream and build-windows-cli actions.
The dist rows use the Linux build. The core total excludes .node files to match the release artifact.

Artifact Format Base PR Change
packages/cli/dist Directory total 2.38 MiB 2.38 MiB 0 B (0.00%)
packages/core/dist Directory total 4.11 MiB 4.11 MiB 0 B (0.00%)
Combined package dist Directory total 6.49 MiB 6.49 MiB 0 B (0.00%)
vp (Linux x64) Binary 8.51 MiB 8.51 MiB 0 B (0.00%)
vp (Linux x64) gzip -9 3.89 MiB 3.89 MiB +1.59 KiB (+0.04%)
NAPI (Linux x64) Binary 37.23 MiB 37.23 MiB 0 B (0.00%)
NAPI (Linux x64) gzip -9 14.87 MiB 14.87 MiB +306 B (+0.00%)
vp (macOS ARM64) Binary 5.57 MiB 5.57 MiB +16 B (+0.00%)
vp (macOS ARM64) gzip -9 3.32 MiB 3.32 MiB +229 B (+0.01%)
NAPI (macOS ARM64) Binary 43.77 MiB 43.77 MiB -16 B (-0.00%)
NAPI (macOS ARM64) gzip -9 19.01 MiB 19.01 MiB +362 B (+0.00%)
vp (Windows x64) Binary 6.59 MiB 6.59 MiB 0 B (0.00%)
vp (Windows x64) gzip -9 3.01 MiB 3.01 MiB +2 B (+0.00%)
NAPI (Windows x64) Binary 33.18 MiB 33.18 MiB 0 B (0.00%)
NAPI (Windows x64) gzip -9 13.60 MiB 13.60 MiB -1 B (-0.00%)
Trampoline (Windows x64) Binary 13.50 KiB 13.50 KiB 0 B (0.00%)
Trampoline (Windows x64) gzip -9 7.09 KiB 7.09 KiB 0 B (0.00%)
Installer (Windows x64) Binary 4.69 MiB 4.69 MiB 0 B (0.00%)
Installer (Windows x64) gzip -9 2.25 MiB 2.25 MiB 0 B (0.00%)

Comment thread crates/vp_command/src/signal_forward.rs Resolved
Comment thread crates/vp_command/src/signal_forward.rs Resolved
Comment thread crates/vp_command/src/lib.rs Resolved
@fengmk2
fengmk2 removed this pull request from stack #3522 November 21, 2026 07:25
@fengmk2

fengmk2 commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Closing. Three review findings come from signal forwarding itself:

  • In a Worker, the native SIGTERM handler replaces the host app's handler.
  • When a supervisor signals the whole process tree, Vite receives SIGTERM twice and stops before its async cleanup finishes.
  • vp exits with code 143 instead of terminating by SIGTERM.

A forwarding wrapper cannot tell a signal sent only to its process ID from a signal sent to the whole tree, so this design cannot fix the second finding. Global vp dev stays as it is on main. A later fix could remove the wrapper processes with exec instead (row 8 of #3106).

@fengmk2 fengmk2 closed this Nov 21, 2026
@fengmk2
fengmk2 deleted the issue-3106-global-dev-signal branch November 23, 2026 13:51
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