Skip to content

Parsed sources collide across assets, and getViewerData mutates input stats #732

Closed

Description

@Menny1337

Problem

Current main (23adc7a) has two independent getViewerData() correctness issues.

Parsed-source lookup is not asset-scoped

Verified with Node 24.18.0 and Webpack 5.105.2:

  • root asset app.js and child-compilation asset worker.js both used module ID 0;
  • their parsed sources were 60 and 182 bytes;
  • the app.js module received the worker source, reporting 182 parsed bytes despite app.js being 116 bytes.

The public test/stats/with-worker-loader fixture also produced two incorrect same-ID source assignments.

getViewerData() currently combines parsed module maps from every asset, keyed only by module ID. IDs reused by separate compilations can therefore overwrite each other.

Analysis mutates the supplied stats

The same reproduction showed that getViewerData():

  • replaced and grew the root assets array from one item to two;
  • removed an asset query string in place;
  • appended the child asset and set isChild;
  • added parsedSrc to the root module.

Calling it again grew the assets array from two items to three.

Expected behavior

  • Resolve parsed sources from the current asset’s module map.
  • Produce chart data without modifying the supplied stats object.
  • Return stable results when called repeatedly with the same input.

Proposed follow-up PRs

  1. Asset-scoped parsed-source lookup

    • Retain parsed module maps per asset.
    • Add regressions for root and child assets that reuse a module ID.
    • Keep input-mutation changes out of scope.
  2. Non-mutating analysis

    • Stop modifying caller-owned asset arrays, asset records, child assets, and modules.
    • Add immutability and repeated-call regressions.
    • Keep parsed-source lookup and unrelated analyzer changes out of scope.

PR #723 changes module selection immediately above the parsed-source loop. Its optimization is semantically separate, but these follow-ups will likely need a textual rebase.

Activity

  1. valscion commented on Aug 21, 2026

    @valscion
    Collaborator

    Yeah #723 was now merged, thanks for pointing to that!

  2. added a commit that references this issue on Sep 2, 2026
    eab49ca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions