Skip to content

Chrome DevTools crashes after refresh when Loading Trace is enabled on Module Info tab #4786

@dmchoi77

Description

@dmchoi77

Describe the bug

Chrome DevTools extension crashes after refreshing the inspected page when Loading Trace is enabled and the Module Info tab is selected.

mf-devtools.mov

In this state, the injected post-message-start script can read window.__FEDERATION__?.moduleInfo before module info is available. The value is undefined, and sanitizePostMessagePayload serializes it as the string "[undefined]".

Because "[undefined]" is truthy, the page message listener can relay it as moduleInfo. getGlobalModuleInfo then stores the value on window.__FEDERATION__.moduleInfo. Later, the Module Info UI iterates over the value and checks fields such as remotesInfo, which can crash because the snapshot is a string rather than a module info object.

Observed console output includes:

moduleInfo: "[undefined]"
originModuleInfo: "[undefined]"

Uncaught TypeError: Cannot use 'in' operator to search for 'remotesInfo' in [
    at main.js:85478:3181
    at Array.map (<anonymous>)
    at Home (main.js:85478:3054)
    at renderWithHooks (main.js:20923:21)
    at updateFunctionComponent (main.js:23069:15)
    at beginWork (main.js:24045:14)
    at performUnitOfWork (main.js:27877:14)
    at workLoopSync (main.js:27754:37)
    at renderRootSync (main.js:27735:7)
    at performWorkOnRoot (main.js:27300:40)

Expected behavior:

The Module Info tab should keep working after refresh, even if module info is temporarily unavailable.

Invalid module info payloads such as "[undefined]", undefined, null, or arrays should be ignored or normalized before they reach the Module Info renderer.

Reproduction

Reproduced with @module-federation/devtools v2.5.0 on a Module Federation application. The minimal reproduction is the DevTools extension itself with the steps above: load the extension from packages/chrome-devtools/dist, open DevTools on a Module Federation page, enable Loading Trace, select Module Info, then refresh the inspected page.

Used Package Manager

pnpm

System Info

System:
  OS: macOS 26.5
  CPU: (8) arm64 Apple M1 Pro
  Memory: 762.05 MB / 32.00 GB
  Shell: 5.9
Binaries:
  Node: 20.19.4
  npm: 10.8.2
  pnpm: 10.28.0
  bun: 1.2.8
  Watchman: 2022.09.19.00
Browsers:
  Chrome: 148.0.7778.181
  Safari: 26.5

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions