Repository navigation
[code-infra] Reduce per-page memory in the browser test suite - #23424
Merged
Merged
Conversation
The browser suite keeps `projects * maxWorkers` pages open for the whole run (vitest-dev/vitest#10990) and every page holds the union of the modules from each file it ran, since `isolate: false` never reloads it. Anything the shared setup pulls in is therefore paid for by all 21 projects, for the whole run. `test/setupVitest.ts` imported `unstable_resetCleanupTracking` from the `@mui/x-data-grid` and `@mui/x-data-grid-pro` barrels. Through the source aliases that evaluates ~650 first-party modules plus `@mui/material`, `@mui/system` and `@mui/utils` in every page — including charts, chat, scheduler, pickers and the rest, none of which touch the grid. Both imports also resolved to the same function, since the pro barrel re-exports `@mui/x-data-grid/hooks`. Move the reset into `test/utils/setupDataGrid.ts` and register it only from the three Data Grid projects. Measured on an `x-date-pickers` page: 47.5MB -> 39.3MB retained JS heap (-17%). Across a full local run, peak RSS drops from 18.15GB to 17.35GB. Also register the crash handler once per page instead of once per test file. `beforeAll` runs per file, so it was adding a duplicate Playwright `page.on('crash')` listener each time and reporting a single crash dozens of times over. The guard lives in a regular module because setup files are re-evaluated per file while their imports stay cached.
Deploy previewBundle size
Check out the code infra dashboard for more information about this PR. |
`test/setupVitest.ts` has always called `server.commands.setupCrashHandler()` without a matching `BrowserCommands` augmentation, but it is not typechecked: `test/tsconfig.json` lists `setupVite.ts` in `include`, which does not exist. Moving the crash-handler registration into `test/utils/` brought it under `utils/**/*`, where it is checked, so the missing declaration surfaced.
JCQuintas
approved these changes
Aug 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
isolate: falsea page is never reloaded, and pages stay open until the whole run ends (vitest#10990) — so whatever the shared setup imports is held by all 21 projects for the entire run.test/setupVitest.tsimportedunstable_resetCleanupTrackingfrom the@mui/x-data-gridand@mui/x-data-grid-probarrels, which through the source aliases evaluates ~650 modules plus@mui/materialin every page — charts, chat, scheduler, pickers, none of which touch the grid. (Both imports were also the same function.) Moved totest/utils/setupDataGrid.ts, registered only by the three Data Grid projects.Also registers the crash handler once per page instead of once per test file, which is why one crash prints dozens of times in CI logs.
x-date-pickerspageBuys headroom; doesn't fix the OOM on its own (vitest#9696, #10990). FWIW the jump to a ~50% failure rate bisects to a single commit, #22807.
Testing: full browser suite passes (758 files);
x-data-grid*andx-date-pickers*jsdom match master, including its existing flakes.