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]: Test runner captures and source-maps stacks that it never uses #44334
Two hot paths in the worker format stacks that nobody reads:
Built-in fixture steps (page, context, request, and about 30 more) have no user location. In fixtureRunner.ts, _stepInfo.stack is undefined, so testInfo._addStep() captures and source-maps a full raw stack, then filters it to 0 frames. This happens about 60 times per test.
LongStandingScope._race() in packages/isomorphic/manualPromise.ts reads new Error().stack on every call. The formatted stack is used only when the scope closes during the race.
Measurements
CPU profile of a 24-test suite, Apple Silicon, Chromium headless shell, 1 worker, median of 5 runs:
Now
With both changes
Worker CPU time
995 ms
806 ms (−19%)
Proposed approach
Give built-in fixture steps stack: []. User fixtures keep their registration location.
In _race(), keep the Error and read .stack only when it clones a close error. V8 records the frames when the Error is constructed, so close messages stay the same.
One difference: built-in fixture steps no longer report user locations injected by a custom Error.prepareStackTrace formatter. With the default formatter, they never had a location.
Already implemented and tested in #44326, which was closed only to file this issue first. Both are small, low-risk performance fixes. Reopening #44326 is the fastest path; it is ready for review.
Hi, I'm the Playwright bot. I checked both stack paths.
Reproduced on macOS at d70f422f491cfb875dd5dc05f01c61207e7382b4 (1.66.0-next). Built-in fixture steps fall back to capturing a stack despite having no user location; scope races format their captured stack even when the promise succeeds. The proposal supplies empty fixture stacks and reads the scope stack only when creating a close error. User fixture locations and the close error's original caller remain intact.
Custom Error.prepareStackTrace hooks will no longer run for built-in fixture steps; for scope errors, they run at close rather than when the race starts. I verified the removed formatting work, not the reported 19% CPU reduction.
Regression checks
The existing should report api step hierarchy test now counts formatter calls whose frames include both _addStep and Fixture. Its zero-call assertion fails without the fixture change and passes with it; the existing step-location expectations still pass.
The new MP-001 should format scope race stacks only on close unit test checks the scope directly. Its central check is:
Here iso is imported from the repository's playwright-core/lib/coreBundle. Without the change, a successful scope race formats its stack once. With the change, it formats none; closing the pending race formats one and preserves its caller.
What I ran
Installed the pinned dependencies with npm ci --no-audit --no-fund, then installed Chromium, Firefox, and WebKit. Initial setup checks failed only because dependencies and browser executables were absent.
npm run build and npm run flint: pass. The new test has its required identifier and test-registry entry.
npm run test -- tests/library/unit/manual-promise.spec.ts tests/library/page-close.spec.ts tests/library/browsercontext-basic.spec.ts tests/page/workers.spec.ts --workers=4 --retries=0 --reporter=dot: 224 passed, 7 existing skips across Chromium, Firefox, and WebKit.
Rebuilt with the two source files restored to the exact base: the fixture regression failed and the scope regression failed in all three browser projects. Restored the fix, rebuilt, and reran both: the fixture check and all three scope checks passed.
These are Node.js stack checks; no browser-specific difference was found. The linked #44326 is closed and unmerged, and has no regression test. No open team PR linking this issue appeared during the final check.
Activity
microsoft-playwright-automation commentedon Nov 24, 2026
microsoft-playwright-automation commentedon Nov 24, 2026
Hi, I'm the Playwright bot. I checked both stack paths.
Reproduced on macOS at
d70f422f491cfb875dd5dc05f01c61207e7382b4(1.66.0-next). Built-in fixture steps fall back to capturing a stack despite having no user location; scope races format their captured stack even when the promise succeeds. The proposal supplies empty fixture stacks and reads the scope stack only when creating a close error. User fixture locations and the close error's original caller remain intact.Custom
Error.prepareStackTracehooks will no longer run for built-in fixture steps; for scope errors, they run at close rather than when the race starts. I verified the removed formatting work, not the reported 19% CPU reduction.Regression checks
The existing
should report api step hierarchytest now counts formatter calls whose frames include both_addStepandFixture. Its zero-call assertion fails without the fixture change and passes with it; the existing step-location expectations still pass.The new
MP-001 should format scope race stacks only on closeunit test checks the scope directly. Its central check is:Here
isois imported from the repository'splaywright-core/lib/coreBundle. Without the change, a successful scope race formats its stack once. With the change, it formats none; closing the pending race formats one and preserves its caller.What I ran
npm ci --no-audit --no-fund, then installed Chromium, Firefox, and WebKit. Initial setup checks failed only because dependencies and browser executables were absent.npm run buildandnpm run flint: pass. The new test has its required identifier and test-registry entry.npm run ttest -- test-step.spec.ts fixtures.spec.ts reporter-json.spec.ts reporter-list.spec.ts reporter-line.spec.ts --workers=4: 172 passed.npm run test -- tests/library/unit/manual-promise.spec.ts tests/library/page-close.spec.ts tests/library/browsercontext-basic.spec.ts tests/page/workers.spec.ts --workers=4 --retries=0 --reporter=dot: 224 passed, 7 existing skips across Chromium, Firefox, and WebKit.These are Node.js stack checks; no browser-specific difference was found. The linked #44326 is closed and unmerged, and has no regression test. No open team PR linking this issue appeared during the final check.
Draft PR: #44338
Triaged on macOS by the Playwright bot - agent run