mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-13 08:13:30 +09:00
## Summary - start managed POSIX preview servers in their own process group - terminate the complete preview process group from `preview.stop` - clean up the owned preview group before propagating `SIGHUP`, `SIGINT`, or `SIGTERM` - preserve the existing child-process fallback on Windows - keep standalone `webstudio preview` signal behavior unchanged ## Root cause The managed preview controller spawned an npm wrapper and stopped only that direct child with `ChildProcess.kill()`. React Router runs below that wrapper, so the dev server could survive as an orphan. Its inherited stdout/stderr pipes could also keep `webstudio mcp run` alive after the manifest had completed. ## Impact `preview.stop` now terminates the npm wrapper and all descendants. If the CLI is terminated while it owns a managed preview, it kills that process group before re-propagating the original signal to itself. ## Todo - [x] Reproduce the missing process-group cleanup in regression tests - [x] Isolate managed POSIX previews in their own process group - [x] Stop the full group on `preview.stop` - [x] Stop the full group on CLI termination signals - [x] Preserve standalone preview behavior - [x] Run an independent real subprocess test with an npm wrapper and long-lived grandchild - [x] Review documentation impact — existing MCP documentation already describes `preview.stop` as ending the owned preview, so no docs change is required - [x] Verify fixture impact — no fixture inputs or generated outputs are affected ## Verification - `pnpm --filter webstudio test` — 58 files, 945 tests passed - `pnpm --filter webstudio typecheck` — passed - targeted `oxlint`, `oxfmt`, and `git diff --check` — passed - regression tests were demonstrated failing without the process-group and signal cleanup, then passing with it - independent real-process test on macOS / Node 22.22.1: - `preview.stop` removed the npm wrapper, server, and long-lived grandchild in 458 ms; harness exited in 0.93 s - parent `SIGTERM` removed the complete process group in 0.01 s; harness exited with expected status 143 - all observed PIDs were absent afterward - agent evaluations were not run because they require separate explicit approval Closes #5958