Skip to content

fix: handle child stats without root assets#717

Open
puneetdixit200 wants to merge 1 commit into
webpack:mainfrom
puneetdixit200:fix-child-stats-missing-assets
Open

fix: handle child stats without root assets#717
puneetdixit200 wants to merge 1 commit into
webpack:mainfrom
puneetdixit200:fix-child-stats-missing-assets

Conversation

@puneetdixit200
Copy link
Copy Markdown

What

Initialize the selected child stats object's assets array before appending assets from later child compilations.

Why

When root stats contain only children, and the first child has no assets while a later child does, getViewerData() currently tries to push into undefined and crashes before producing chart data. This is one of the missing-stats-shape cases discussed in #490.

How

Added a focused regression test for that stats shape and guarded the selected child stats with an empty assets array before merging later child assets.

Validation

  • NODE_OPTIONS=--openssl-legacy-provider npx jest test/analyzer-get-viewer-data.js --runInBand failed before the fix with Cannot read properties of undefined (reading 'push')
  • NODE_OPTIONS=--openssl-legacy-provider npx jest test/analyzer-get-viewer-data.js --runInBand
  • npm run build
  • NODE_OPTIONS=--openssl-legacy-provider npx jest test/analyzer-get-viewer-data.js test/analyzer.js --runInBand --testTimeout=60000
  • npm run lint
  • git diff --check

Note: I also tried the full Jest suite with --testTimeout=60000; the analyzer tests passed, but the run failed in test/plugin.js after 128 passed / 4 skipped due to a local Puppeteer afterEach browser cleanup timeout.

Copilot AI review requested due to automatic review settings June 4, 2026 06:33
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 4, 2026

⚠️ No Changeset found

Latest commit: 7b233e2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@linux-foundation-easycla
Copy link
Copy Markdown

CLA Missing ID

  • ❌ The email address for the commit (7b233e2) is not linked to the GitHub account, preventing the EasyCLA check. Consult this Help Article and GitHub Help to resolve. (To view the commit's email address, add .patch at the end of this PR page's URL.) For further assistance with EasyCLA, please visit our EasyCLA portal and chat with our support bot.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR fixes a crash/incorrect handling in getViewerData when bundle stats are stored in children and the “root” child compilation has no assets array, and adds a regression test for that scenario.

Changes:

  • Default bundleStats.assets to an empty array after selecting the root child compilation.
  • Add a test case covering “root child has no assets, but another child contains assets/modules”.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
test/analyzer-get-viewer-data.js Adds a regression test ensuring child assets are still surfaced when the root child has no assets.
src/analyzer.js Ensures bundleStats.assets is initialized after switching bundleStats to the first child compilation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/analyzer.js
) {
const { children } = bundleStats;
[bundleStats] = bundleStats.children;
bundleStats.assets ||= [];
@alexander-akait
Copy link
Copy Markdown
Member

Please accept CLA and fix copilot review

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.

3 participants