Repository navigation
test(cli): make browser timeout cleanup independent of child startup - #12254
Conversation
Re-cut of #12184 by astracat-bot, byte for byte on current main. Co-authored-by: astracat-bot[bot] <323722387+astracat-bot[bot]@users.noreply.github.com>
|
AI review status for this pull request.
|
|
/approve-spec ec1d597 |
PR Analysis Report🔎 Preview ·
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Approved. CI's run on this head passed, including the node test shard that runs this file.
The timeout case now holds the 1500 ms bound with fake timers until the stand-in has written its record, so a slow child startup can no longer fail it before cleanup is checked. With Node startup delayed by two seconds, the old test fails with ENOENT and the new one passes, also merged into main.
- Non-blocking: if an assertion fails before the bound is advanced, the stand-in process and its temp folder stay until the test worker exits; advancing the bound and awaiting
runninginfinally, beforevi.useRealTimers(), stops it (see the existing inline comment on line 121).
Claims and files checked
Review mode: same-head; reason: none
- changed rules (0): none
- Claim: the change repeats the earlier pull request it re-cuts line for line, on current
main, with credit in a co-author trailer. Verified: the 25 added and removed lines are identical (the earlier pull request's hunk starts one line earlier), and the commit carries the trailer. - Claim: a slow child can use up the 1500 ms bound before it writes its record, so the old test fails reading it before it checks cleanup. Verified: with a two-second startup delay the base test fails with
ENOENTat the record read. - Claim: the first failing commit changes an unrelated smoke check, so this is a startup race, not a regression. Partly verified: that commit only touches the CLI global-mode smoke script and its test; the failing unit run itself could not be found.
- Claim: no behavior change; a bounded run must still report
timedOutand remove its temp profile folder. Verified: only this test file changes, and lines 117 and 118 still assert both. - Claim: fake timers apply only to this test. Verified: installed on line 103 and restored on line 121.
- Claim: the test waits for the record through a filesystem watcher, checks the profile folder, then advances the same 1500 ms bound. Verified: lines 94-101, 114 and 115.
- Claim: the real child process, process-group stop and folder removal still run. Verified: the module mock passes
runBrowserthrough unchanged, and after the advance it stops the group and removes the folder. - Claim: every original assertion remains, and the profile check shows that cleanup removes a folder the child used. Verified: lines 113, 117 and 118 remain, and the stand-in makes the profile folder before it writes its record.
- Claim: the test timeout and production code are unchanged. Verified: the 30-second timeout stays on line 124, and no other file changes.
- Claim: the delayed-startup reproduction fails on the earlier commit and on
main. Partly verified: the same failure reproduces on the base, which contains both commits; the commits themselves were not run. - Claim: all six tests pass, and the timeout case passes with ordinary and with delayed startup, 20 runs each. Verified for six of six with ordinary and with delayed startup, merged into
main; the 20-run repeats were not rerun. - Claim: the repeat option and the startup preload used while testing are not part of the change. Verified from the diff.
- Claim: ESLint, Prettier, the spec lookup and the pre-review report pass. Verified: ESLint and Prettier pass on the file, and the pre-review report lists no findings and no baseline claims.
- Claim: a separate lab reproduction was requested and is not counted as evidence. Not relied on.
- Claim: keeping the real child, rather than a mock, keeps process and filesystem coverage. Verified: no process or filesystem call is mocked in this case.
- Claim: the scope is the CLI browser-run test only, and the fixed test is the browser run's timeout case. Verified: one file under
packages/cli, the case on line 91. - Claim: #12097 also changes this test file. Verified: it did, and it is merged into the base.
- Notes on who drives and lands the change, and on closing the original pull request: process statements, not code claims.
- File
packages/cli/api/theme-edit/theme-preview-follows-through-browser.test.mjs: one non-blocking finding (above); otherwise clear.
| watcher.close(); | ||
| vi.useRealTimers(); |
There was a problem hiding this comment.
Non-blocking: if an assertion above fails before line 115, the faked bound is still pending when vi.useRealTimers() runs, so it never fires. The stand-in keeps running and its temp folder stays until the test worker exits. Firing the bound here stops it on every path, with let running; declared before try:
} finally {
watcher.close();
await vi.advanceTimersByTimeAsync(1500);
await running;
vi.useRealTimers();
fs.rmSync(dir, {recursive: true, force: true});
}On the passing path running has already settled, and the extra advance stays short of the 5 s grace timer.
Re-cut of #12184 by astracat-bot, byte for byte, on current
main: the commit's diff is identical to #12184's. Credit stays with astracat-bot (a Co-authored-by trailer on the commit). The drain shepherd drives it and closes #12184 when this one merges.validation: ran
pnpm test:node packages/cli/api/theme-edit/theme-preview-follows-through-browser.test.mjs --maxWorkers=4: all 6 tests passed; the timeout case also passed 20/20 with ordinary startup and 20/20 with a two-second Node startup preload. ESLint, Prettier, the spec lookup, andpnpm review:prepassed.Maintainer impact
The unit check at f233077 failed with
ENOENTwhen the timeout test read its stand-in script'stemprecord. The browser run had correctly timed out, but a slow child process can exhaust the 1500 ms bound before it writes that record. The test then fails before it can check cleanup.The first failing commit changes an unrelated smoke check. This is a startup race in the existing test, not a regression in that commit's code.
Intended invariant and change
No behavior change. A bounded browser run must still report
timedOutand remove its own temporary profile folder.Use fake timeout timers only in this test. Observe the stand-in's completed record through a filesystem watcher, verify that its profile exists, then advance the same 1500 ms bound. The real child process, process-group stop, and filesystem cleanup still run. Every original assertion remains; the profile-existence assertion additionally proves that cleanup removes a folder the child used. The test timeout and production code are unchanged.
Evidence
repeats: 19option ran the timeout case 20 times with that same startup delay and 20 times without it: all 40 passed. The other five tests passed in both suite runs. The repeat option and preload are not included in the change.This test checks timeout classification and cleanup, not whether the operating system can start Node within 1.5 seconds. The alternative would be to replace the process with a mock; keeping the real child retains the process and filesystem coverage.
Scope
Components: CLI browser-run test only.
Fixes test
0155f792dcf50f850793369fe45229446c36f7f7e988c53dfc6bd6003b395d24:packages/cli/api/theme-edit/theme-preview-follows-through-browser.test.mjs › the browser run › a run stopped at the bound is said to have timed out, and its temp folder goes.See also #12097.
#12097 by josephfarina also changes this test file.
Overlap checked: #12184 (astracat-bot's original of this same change, byte for byte; it closes when this re-cut merges)
Owning session: noopbot (a61f66c2), under CI & Release (ca77f950); driven by the drain shepherd (66fc5b74). Land path: the shipper, through merge-guard.