fix(workbench): exit the dev process after signal-triggered teardown#1290
Draft
gu-stav wants to merge 2 commits into
Draft
fix(workbench): exit the dev process after signal-triggered teardown#1290gu-stav wants to merge 2 commits into
gu-stav wants to merge 2 commits into
Conversation
Contributor
📦 Bundle Stats —
|
| Metric | Value | vs fix/workbench-rebuild-registry (724a139) |
|---|---|---|
| Internal (raw) | 2.7 KB | - |
| Internal (gzip) | 1.1 KB | - |
| Bundled (raw) | 11.15 MB | - |
| Bundled (gzip) | 2.10 MB | - |
| Import time | 862ms | -12ms, -1.4% |
bin:sanity
| Metric | Value | vs fix/workbench-rebuild-registry (724a139) |
|---|---|---|
| Internal (raw) | 782 B | - |
| Internal (gzip) | 423 B | - |
| Bundled (raw) | 9.87 MB | - |
| Bundled (gzip) | 1.77 MB | - |
| Import time | 2.01s | -36ms, -1.8% |
🗺️ View treemap · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
📦 Bundle Stats — @sanity/cli-core
Compared against fix/workbench-rebuild-registry (724a139e)
| Metric | Value | vs fix/workbench-rebuild-registry (724a139) |
|---|---|---|
| Internal (raw) | 105.5 KB | - |
| Internal (gzip) | 25.8 KB | - |
| Bundled (raw) | 21.71 MB | - |
| Bundled (gzip) | 3.45 MB | - |
| Import time | 775ms | -8ms, -1.0% |
🗺️ View treemap · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
📦 Bundle Stats — create-sanity
Compared against fix/workbench-rebuild-registry (724a139e)
| Metric | Value | vs fix/workbench-rebuild-registry (724a139) |
|---|---|---|
| Internal (raw) | 908 B | - |
| Internal (gzip) | 483 B | - |
| Bundled (raw) | 931 B | - |
| Bundled (gzip) | 491 B | - |
| Import time | ❌ ChildProcess denied: node | - |
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
Contributor
Preview this PR with pkg.pr.newRun the Sanity CLInpx https://pkg.pr.new/sanity-io/cli/@sanity/cli@42b61f2 <command>...Or upgrade project dependencies📦
|
Contributor
Coverage Delta
Comparing 69 changed files against main @ Overall Coverage
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closing
sanity devvery often leaves the dev server running in the background, still holding its ports. Root cause: the workbench signal handler traps SIGINT/SIGTERM (which disables Node's default exit) and runs the teardown, but never exits. Any handle that survives teardown — keep-alive sockets, an extraction worker mid-run, a mid-rebuild server — keeps the event loop alive forever. Under a wrapper (pnpm, turbo, Nix supervisors) the wrapper dies on the same signal and returns the prompt while the node process lingers detached, so a second Ctrl-C never reaches it.The handler now re-raises the signal once teardown settles — the
oncehandler is gone by then, so the default termination runs with conventional signal exit semantics. An unref'd 5s timer covers a teardown that never settles, without itself keeping the process alive.Two shutdown races fixed alongside, since the forced exit would otherwise just paper over them:
oncehandler), or a signal racing the caller's own close(), ran two concurrent teardowns. close() is single-flight now.A hung manifest-extraction worker (no timeout, runs user config under jsdom) was the third hole found in the investigation — deliberately left alone here, since the re-raise kills it along with the process.
Stacked on #1289 (touches the same
onInterfaceSetChangepath); retarget tofeat/workbenchonce that merges.What to review
All in
devAction.ts: theonSignalre-raise + grace timer, the memoizedclose(), and theclosedguard inrunRebuild(checked before the first await, so a rebuild can't slip past a close() that already readrebuildInFlight).Testing
devAction.test.tscovers the re-raise after teardown (with ordering), the force-exit on a hung close, close() waiting for an in-flight rebuild, single-flight close, and the refused-rebuild-during-shutdown path.