Skip to content

test(snapshot): reproduce vp run ctrl-c tearing tasks down mid-shutdown#2069

Closed
fengmk2 wants to merge 1 commit into
mainfrom
issue-2036-snapshot-repro
Closed

test(snapshot): reproduce vp run ctrl-c tearing tasks down mid-shutdown#2069
fengmk2 wants to merge 1 commit into
mainfrom
issue-2036-snapshot-repro

Conversation

@fengmk2

@fengmk2 fengmk2 commented Jul 6, 2026

Copy link
Copy Markdown
Member

Reproduces #2036 with a PTY snapshot test.

The stray characters after killing vp run in fish are the terminal's replies to fish's own prompt probes (fish 4.x sends OSC 11, CSI 6n, and DA1 at every prompt draw). The vp-side defect that turns them into garbage: on Ctrl+C, vp run tears the task down within a few milliseconds instead of waiting for its graceful shutdown, so the dying task tree (vite dev server, managed node) still touches the terminal while the shell is already drawing its next prompt. Plain vite dev is clean because the shell waits for vite itself, which finishes its terminal cleanup before exiting. Verified end to end by driving real fish 4.8 in a scripted PTY: vp run dev reproduces the exact junk from the issue, a plain node process killed the same way does not.

The new run_ctrlc_teardown fixture pins this: a dev-server-like vpt payload whose shutdown takes 300 ms records whether that shutdown was allowed to finish. The verdict is written by a watcher process in its own process group (it survives vp's teardown the same way real dev-server grandchildren do) and read by a follow-up vpt wait-file step, which keeps the snapshot deterministic under parallel suite load. The recorded snapshot currently says:

task was torn down before its graceful shutdown finished

A fix should flip this line to task completed its graceful shutdown.

Also adds vpt wait-file <path> [timeout-ms], a generic helper that polls until a file exists and prints it.

Killing a vp run task with Ctrl+C in fish leaves stray escape sequences on
the next prompt: fish probes the terminal (OSC 11, CSI 6n, DA1) at every
prompt draw, and vp run tears the task down within milliseconds of Ctrl+C
instead of waiting for its graceful shutdown, so the dying task tree's late
terminal writes and mode restores race the shell's probes and the replies
land as garbage input.

The new run_ctrlc_teardown fixture pins the vp-side defect: a
dev-server-like vpt payload whose shutdown takes 300 ms records, via a
watcher process in its own process group that survives vp's teardown,
whether that shutdown was allowed to finish. verdict.txt currently reads
"task was torn down before its graceful shutdown finished"; a fix should
flip it to "task completed its graceful shutdown".

Also adds vpt wait-file, a generic helper that polls until a file exists
and prints it, for asserting on files written by a step's surviving
process tree.

Refs #2036
@netlify

netlify Bot commented Jul 6, 2026

Copy link
Copy Markdown

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit 36e5e8b
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a4bd3c26dbfb000084504d9

fengmk2 commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add the label auto-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@fengmk2

fengmk2 commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

Consolidated into #2065: the snapshot reproduction commit is included on that branch together with the fix.

@fengmk2 fengmk2 closed this Jul 6, 2026
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