Skip to content

test(snapshots): suppress racy optimizer logs in vitest_browser_mode - #2297

Merged
fengmk2 merged 1 commit into
mainfrom
fix-vitest-browser-mode-flaky
Aug 3, 2026
Merged

test(snapshots): suppress racy optimizer logs in vitest_browser_mode#2297
fengmk2 merged 1 commit into
mainfrom
fix-vitest-browser-mode-flaky

Conversation

@fengmk2

@fengmk2 fengmk2 commented Aug 2, 2026

Copy link
Copy Markdown
Member

The vitest_browser_mode PTY snapshot fails intermittently with an extra line:

+2:02:47 PM [vite] (client) [optimizer] bundling dependencies...

Example failure: https://github.com/voidzero-dev/vite-plus/actions/runs/30750855536/job/91504582504?pr=2248

Vite's dep optimizer emits [optimizer] bundling dependencies... (and its sibling [optimizer] scanning dependencies...) on a 1s setTimeout (vite/src/node/optimizer/index.ts), so the line only appears when a cold-cache bundle takes longer than 1s on a slow runner. The fixture already suppresses known non-deterministic Vite logs through a logger patch; this extends that filter to drop [optimizer] progress lines. The environment logger looks up config.logger.info at call time, so the patch intercepts these messages. The recorded snapshot is unchanged.

@fengmk2 fengmk2 self-assigned this Aug 2, 2026
@netlify

netlify Bot commented Aug 2, 2026

Copy link
Copy Markdown

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit 098a8dc
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a702082a3a4180008de67aa

@fengmk2
fengmk2 marked this pull request as ready for review August 3, 2026 01:50
@fengmk2
fengmk2 requested review from cpojer and wan9chi August 3, 2026 01:50
@fengmk2
fengmk2 force-pushed the fix-vitest-browser-mode-flaky branch from 964fc78 to 5bd9804 Compare August 3, 2026 01:50
@fengmk2
fengmk2 force-pushed the fix-vitest-browser-mode-flaky branch 2 times, most recently from 9ec4642 to dd26887 Compare August 3, 2026 03:57
Vite's dep optimizer logs "[optimizer] bundling dependencies..." and
"[optimizer] scanning dependencies..." on a 1s timer, so the lines only
appear when a cold-cache run is slow enough, breaking the snapshot.

Extend the fixture's known-logs filter to drop them.

Claude-Session: https://claude.ai/code/session_01Q33nALG7fPwXJ3Ltp5DYku
@fengmk2
fengmk2 force-pushed the fix-vitest-browser-mode-flaky branch from dd26887 to 098a8dc Compare August 3, 2026 05:00
@fengmk2
fengmk2 merged commit f10e597 into main Aug 3, 2026
82 of 86 checks passed
@fengmk2
fengmk2 deleted the fix-vitest-browser-mode-flaky branch August 3, 2026 06:28
fengmk2 added a commit that referenced this pull request Aug 3, 2026
…#2299)

The `env_install_interrupt` PTY snapshot fails intermittently on
Windows:

```
+**Exit code:** 1
-interrupted stale package exists
+interrupted stale package removed
```

Example failure:
https://github.com/voidzero-dev/vite-plus/actions/runs/30777846280/job/91576844864?pr=2297

`taskkill /T /F` terminates the process tree in unspecified order. When
the postinstall child dies before `vp.exe`, vp observes the failed npm
child and runs `cleanup_failed_install`, removing the partial install
dir before taskkill reaches vp itself, so no stale dir is left for the
check-stale step. Reproduced the mechanism on macOS by killing the
postinstall child first and letting vp react: same diff as the CI
failure.

Fix: enumerate vp's direct children while the tree is parked in the
postinstall sleep, kill `vp.exe` first so it cannot react, then
`taskkill /T` each orphaned child (killing vp alone would leave the
installer children running). The Unix path and the recorded snapshot are
unchanged.

Stacked on #2297.
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.

2 participants