Skip to content

test(cli): make browser timeout cleanup independent of child startup - #12184

Closed
astracat-bot[bot] wants to merge 1 commit into
mainfrom
codebunny/fix/test-cli-make-browser-timeout-cleanup-independent-of-child-startup-843a05
Closed

astracat-bot[bot] wants to merge 1 commit into
mainfrom
codebunny/fix/test-cli-make-browser-timeout-cleanup-independent-of-child-startup-843a05

Conversation

@astracat-bot

@astracat-bot astracat-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

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, and pnpm review:pre passed.

Maintainer impact

The unit check at f233077 failed with ENOENT when the timeout test read its stand-in script's temp record. 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 timedOut and 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

  • With unchanged tracked code, a Node preload that awaits a two-second timer reproduced the exact missing-record failure in 2/2 runs at f233077, and 2/2 on current main 5a3fd39. Ordinary startup passed, consistent with the race.
  • With the fix, Vitest's temporary repeats: 19 option 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.
  • After restoring the normal test declaration, the submitted file passed its complete six-test suite again. ESLint and Prettier passed; pre-review reported no findings.
  • CodeBunny CI lab repro 3989755178234518597 was requested for 20 runs at the failing commit. It remains running with 0 completed runs and no log; it is not credited as reproduction or validation evidence. The local controlled-startup reproduction and repeat results above are the evidence for this fix.

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.

@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 16, 2026 10:34pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 16, 2026
@astracat-bot

astracat-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 17, 2026, 8:04 AM UTC

@astracat-bot

astracat-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

This test passes on main now, but no commit on main touched it, so this PR stays open as the fix.

@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · ab7e070

Storybook · Sandbox · built from this PR's head

Current run: The current CI run concluded cancelled. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, finally restores 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 ENOENT on 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.

Automated review (maintainer link)

expect(fs.existsSync(temp)).toBe(false);
} finally {
watcher.close();
vi.useRealTimers();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.)

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec ab7e070

cixzhang added a commit that referenced this pull request Nov 18, 2026
…12254)

test(cli): make browser timeout cleanup independent of child startup

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>
@github-actions
github-actions Bot deleted the codebunny/fix/test-cli-make-browser-timeout-cleanup-independent-of-child-startup-843a05 branch November 19, 2026 06:05

This branch was successfully deployed

1 active deployment
Preview — ab7e0709 Deployed Nov 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant