fix: render ProfilingPlugin trace in Chrome DevTools#21269
Conversation
🦋 Changeset detectedLatest commit: e6247a4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
This PR is packaged and the instant preview is available (ed9fa71). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@ed9fa71
yarn add -D webpack@https://pkg.pr.new/webpack@ed9fa71
pnpm add -D webpack@https://pkg.pr.new/webpack@ed9fa71 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21269 +/- ##
=======================================
Coverage 92.85% 92.86%
=======================================
Files 592 592
Lines 65024 65024
Branches 18163 18163
=======================================
+ Hits 60379 60382 +3
+ Misses 4645 4642 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will not alter performance
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Memory | benchmark "many-modules-esm", scenario '{"name":"mode-development","mode":"development"}' |
1.1 MB | 1.9 MB | -41.03% |
| ❌ | Memory | benchmark "wasm-modules-async", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
187.6 KB | 247.7 KB | -24.29% |
| ❌ | Memory | benchmark "devtool-eval-source-map", scenario '{"name":"mode-production","mode":"production"}' |
6.4 MB | 8.1 MB | -20.91% |
| ⚡ | Memory | benchmark "wasm-modules-sync", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
252.7 KB | 132.8 KB | +90.32% |
| ⚡ | Memory | benchmark "asset-modules-inline", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
1,194.8 KB | 800.9 KB | +49.17% |
| ⚡ | Memory | benchmark "json-modules", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
364.7 KB | 280.5 KB | +30.03% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing fix/profiling-plugin-chrome-frames (e6247a4) with main (322b060)
6daa1a7 to
7c5d64c
Compare
Chrome DevTools' performance panel treats TracingStartedInBrowser as the primary trace-bootstrap event and iterates args.data.frames. The plugin emitted that event without a frames array, so loading the generated events.json failed with "frames is not iterable". Add the frames array (matching the sibling TracingStartedInPage event) so the trace loads. Closes #17234
Launch headless Chrome and run DevTools' frame-bootstrap iteration over the plugin-generated events.json. The test self-skips when puppeteer or a working Chrome is unavailable.
puppeteer requires Node 18+ and its postinstall fails to parse on the Node 10.x/12.x install matrix, so it cannot be a committed devDependency. Drop it from package.json, exclude the browser test from the types-test tsc pass, and add a dedicated latest-LTS CI job that installs puppeteer on demand and runs the test. The test self-skips wherever puppeteer or Chrome is unavailable.
…er-core Replace the dedicated latest-LTS CI job with a committed puppeteer-core devDependency (no postinstall, so it installs cleanly on the legacy-Node matrix) and run the browser check in the unit suite instead of the integration matrix. It launches the runner's installed Chrome and self-skips when none is available or under the Bun/Deno runtimes.
Replace EXPECTED_ANY in the browser test with real puppeteer-core types (Browser/LaunchOptions) and a typed trace-event shape, and skip when Node < 18 (puppeteer-core's minimum runtime). Document in AGENTS.md that specific real types and generics are preferred over EXPECTED_ANY/OBJECT/FUNCTION.
Gate the require behind the same Node >= 18 / not-Bun-or-Deno check used to run the test, so the heavy puppeteer-core module graph is never loaded into the memory-limited Bun/Deno workers running the full suite.
cb7e97a to
669d299
Compare
Bun's Node `inspector` CPU profiler never resolves, so this test hung the full Bun runtimes suite until its 120s timeout. It runs unchanged under Node, where the V8 inspector is fully supported.
Types CoverageCoverage after merging fix/profiling-plugin-chrome-frames into main will be
Coverage Report |
Summary
Closes #17234.
ProfilingPluginemitted theTracingStartedInBrowserevent with onlysessionIdinargs.data. Modern Chrome DevTools treats that as the primary trace-bootstrap event and iteratesargs.data.frames, so loading the generatedevents.jsonfailed withframes is not iterable(Firefox's profiler is more lenient, which is why the same file still works there). This adds theframesarray, mirroring the siblingTracingStartedInPageevent.What kind of change does this PR introduce?
fix
Did you add tests for your changes?
Yes — a fast deterministic assertion in
test/configCases/plugins/profiling-plugin/index.jsthat replays Chrome DevTools' frame-bootstrap over the generatedevents.json, plus an optional real-browser end-to-end check intest/ProfilingPlugin.unittest.jsthat loads the trace in headless Chrome viapuppeteer-coreand self-skips when no Chrome (or an old Node/Bun/Deno runtime) is available.Does this PR introduce a breaking change?
No.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a
Use of AI
Yes. AI (Claude Code) assisted with the root-cause investigation against Chrome's trace-engine source, the fix, the tests, and this description. All changes were reviewed by me and verified by running the test suite.