You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature]: Enable the Node.js module compile cache in the CLI and test workers #44347
Each playwright test run starts a runner process and one or more worker processes. Each process compiles Playwright's bundled JavaScript again from source. Node.js 22.8 and later can cache the compiled code on disk with module.enableCompileCache(), but Playwright does not enable it.
Measurements
Apple Silicon, Node.js 24.22.1, Chromium headless shell, main at 61775c1, hyperfine mean of 10 runs after 2 warm-up runs. The cache was enabled with the NODE_COMPILE_CACHE environment variable, which enableCompileCache() uses.
Command
Now
With the compile cache
playwright test --list
311 ms
240 ms (−23%)
One-test run, 1 worker
976 ms
815 ms (−16%)
The cache directory was 1.8 MB. The gain is per process, so a run with more workers saves more. The first run after an install or upgrade is cold and compiles as before.
Proposed approach
Call require('module').enableCompileCache?.() at the top of packages/playwright/cli.js, packages/playwright-test/cli.js, and packages/playwright-core/cli.js, before the first require of ./lib.
Forked test workers do not inherit the setting: with Node.js 24.22.1, a child started by child_process.fork() after enableCompileCache() reports no cache directory. Add the same call at the top of the worker entry (packages/playwright/src/worker/workerProcessEntry.ts), for example as an esbuild banner in utils/build/build.js.
The optional call is a no-op on Node.js 20 and on 22 before 22.8. NODE_DISABLE_COMPILE_CACHE=1 still turns the cache off.
Found and measured on main at 61775c1. The change is small and ready to implement as described.
Hi, I'm the Playwright bot and I checked this request.
Verified and implemented in a proposal. On macOS with Node.js 24.22.3, the change reduced playwright test --list from 310.0 ms to 240.3 ms (-22.5%) and a one-test Chromium run from 760.5 ms to 631.1 ms (-17.0%). Cache activation is per process, so the worker also needs to enable it before loading dependencies.
The change uses Node.js's existing cache directory settings and preserves NODE_DISABLE_COMPILE_CACHE=1. The documentation notes the opt-out for precise V8 coverage.
playwright, @playwright/test, and playwright-core CLI entries
Cache enabled before dependencies load
Forked workers from both test CLI entries
Cache enabled before dependencies load
NODE_DISABLE_COMPILE_CACHE=1
Cache remained disabled in CLIs and workers
Unavailable enableCompileCache API, simulated on Node.js 24.22.3
CLIs and workers ran without enabling the cache
Default storage
Compiled-code cache files persisted on disk
Chromium, Firefox, and WebKit
Browser smoke tests passed with caching enabled and disabled
Regression test
Failed without CLI activation; also failed with only worker activation removed; passed with the complete change
Cache, loader, worker-index, and list-mode tests
All 87 passed
npm run build and npm run flint
Passed after installing required browsers and increasing the lint command's Node.js heap limit
Timing results are means of 10 runs per mode after two warm-up runs, with enabled and disabled runs alternating. The disabled mode uses NODE_DISABLE_COMPILE_CACHE=1. These are local measurements, not a performance guarantee. Other operating systems and an actual older Node.js runtime were not tested.
Activity
microsoft-playwright-automation commentedon Nov 24, 2026
microsoft-playwright-automation commentedon Nov 24, 2026
Hi, I'm the Playwright bot and I checked this request.
Verified and implemented in a proposal. On macOS with Node.js 24.22.3, the change reduced
playwright test --listfrom 310.0 ms to 240.3 ms (-22.5%) and a one-test Chromium run from 760.5 ms to 631.1 ms (-17.0%). Cache activation is per process, so the worker also needs to enable it before loading dependencies.The change uses Node.js's existing cache directory settings and preserves
NODE_DISABLE_COMPILE_CACHE=1. The documentation notes the opt-out for precise V8 coverage.What I checked
Base: Playwright
1.66.0-next, commitd70f422f491cfb875dd5dc05f01c61207e7382b4.playwright,@playwright/test, andplaywright-coreCLI entriesNODE_DISABLE_COMPILE_CACHE=1enableCompileCacheAPI, simulated on Node.js 24.22.3npm run buildandnpm run flintTiming results are means of 10 runs per mode after two warm-up runs, with enabled and disabled runs alternating. The disabled mode uses
NODE_DISABLE_COMPILE_CACHE=1. These are local measurements, not a performance guarantee. Other operating systems and an actual older Node.js runtime were not tested.Draft PR: #44350
Triaged on macOS by the Playwright bot - agent run