Repository navigation
test(cli): make browser timeout cleanup independent of child startup - #12184
astracat-bot[bot] wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
This test passes on main now, but no commit on main touched it, so this PR stays open as the fix. |
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet. The CI run was turned away for capacity ("CI is full"), so its jobs need a re-run before merge.
The timeout test now waits for the stand-in's record before it advances a fake 1500 ms bound. With a two-second start-up delay the old test fails with ENOENT and the new one passes repeatedly, on this branch and merged with main, and the real stop and temp-folder cleanup are still exercised.
- Non-blocking: if the record read or an assertion before the bound fails,
finallyrestores real timers before the fake bound fires, so the stand-in keeps running and its temp folder stays; settling the run first (await vi.advanceTimersByTimeAsync(1500); await running;) closes that gap.
Claims and files checked
Review mode: same-head; reason: none
- The whole test file passes (six tests): verified at this head and merged with
main. - The timeout case passes repeatedly with ordinary start-up and with a two-second start-up delay: verified, 10 of 10 runs each, at this head and merged with
main. - ESLint, Prettier, the spec lookup and the pre-review report pass: verified; pre-review reports no findings.
- The original failure is
ENOENTon the stand-in's record after the bound stops a slow child: verified by reproducing it on the base with a two-second start-up delay. - The first failing commit changed an unrelated smoke check: verified; it touches only the global-mode smoke script and its test.
- No behavior change; production code and the 30-second test timeout are unchanged: verified; only this test file changes.
- Every original assertion remains, and a profile-folder assertion is added: verified at lines 112-117.
- Fake timers are confined to this test: verified; installed at line 102 and restored at line 120.
- The real child process, group stop and cleanup still run: verified; deleting the temp-folder removal from the stop path makes the test fail at line 117.
- Another pull request edits this file: verified; it has since merged and changes only the picture stand-in mock, not this test.
- A separate repeat run that had not finished is not credited as evidence: a statement about evidence, with nothing in the code to check.
packages/cli/api/theme-edit/theme-preview-follows-through-browser.test.mjs: clear apart from the non-blocking note above.
| expect(fs.existsSync(temp)).toBe(false); | ||
| } finally { | ||
| watcher.close(); | ||
| vi.useRealTimers(); |
There was a problem hiding this comment.
Non-blocking: if the record read or an assertion at lines 111-113 fails, this restores real timers before the fake bound has fired, so runBrowser never stops the detached stand-in or removes its temp folder (only its process-exit hook does, later). Settling the run first closes the gap:
} finally {
await vi.advanceTimersByTimeAsync(1500);
await running;
watcher.close();
vi.useRealTimers();
fs.rmSync(dir, {recursive: true, force: true});
}(running would need to be declared before try.)
|
/approve-spec ab7e070 |
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.