Skip to content

[Flight] Strip the full <anonymous>. type name prefix from I/O names - #37856

Merged
eps1lon merged 2 commits into
react:mainfrom
zhoubiao188:scan-2026-10-15
Oct 19, 2026
Merged

eps1lon merged 2 commits into
react:mainfrom
zhoubiao188:scan-2026-10-15

Conversation

@zhoubiao188

Copy link
Copy Markdown
Contributor

Summary

serializeIONode picks the name of an I/O entry from the name of the first first-party function in the stack. That name can include the type name that the function was called on. Since that context is usually not useful, the name is reduced to just the function, e.g. Window.fetch becomes fetch.

The <anonymous>. case copied the slice length straight from the Window. case above it, but that prefix is 12 characters long, not 7. So instead of stripping the prefix it damaged the name:

'<anonymous>.'.length   === 12
'<anonymous>.fetch'.slice(7)  === 'ous>.fetch'   // current, broken
'<anonymous>.fetch'.slice(12) === 'fetch'        // intended

This was introduced in #33392 and is the only place in the repo that strips this prefix.

Reproducing

V8 derives the type name of a method call from the receiver, and Symbol.toStringTag is honored there. An object that reports itself as <anonymous> therefore produces stack frames named <anonymous>.getData:

const client = {
  [Symbol.toStringTag]: '<anonymous>',
  getData(text) {
    return new Promise(resolve => {
      setTimeout(() => resolve(text.toUpperCase()), 1);
    });
  },
};

CallSite.prototype.toString() for that frame is <anonymous>.getData (file:1:1), so this shape is produced by both the structured stack parser and the string stack parser.

Starting I/O from that method, the recorded stack frame is correctly named <anonymous>.getData, but the name reported for the I/O itself — which is what DevTools shows — is mangled:

{
  "awaited": {
    "name": "ous>.getData",
    "stack": [["<anonymous>.getData", ".../ReactFlightAsyncDebugInfo-test.js", 563, 16, 562, 16]]
  }
}

After the fix the reported name is getData.

How did you test this change?

Added a regression test to ReactFlightAsyncDebugInfo-test.js which starts I/O from a method of an object whose Symbol.toStringTag is <anonymous>. It fails before the fix with Expected: "getData" / Received: "ous>.getData", and the test also asserts the recorded stack frame is still <anonymous>.getData so it fails loudly if V8 ever stops producing that shape. The test is appended at the end of the suite so that the line numbers referenced by the existing inline snapshots do not shift.

  • yarn test ReactFlightAsyncDebugInfo --runInBand — 21 passed
  • yarn test ReactFlight --runInBand — 437 passed; the 3 ReactFlightDOMEdge SharedArrayBuffer failures are pre-existing on main (verified by stashing the fix and running the same suite)
  • yarn linc
  • node scripts/prettier/index.js check-changed

## Summary

`serializeIONode` picks the name of an I/O entry from the name of the first
first-party function in the stack. That name can include the type name that
the function was called on. Since that context is usually not useful, the
name is reduced to just the function, e.g. `Window.fetch` becomes `fetch`.

The `<anonymous>.` case copied the slice length straight from the `Window.`
case above it, but that prefix is 12 characters long, not 7. So instead of
stripping the prefix it damaged the name. I/O started from a method of an
object that reports itself as `<anonymous>` through `Symbol.toStringTag` is
reported as `ous>.getData` instead of `getData`.

This was introduced in react#33392.

## How did you test this change?

- Added a regression test that starts I/O from a method of an object whose
  `Symbol.toStringTag` is `<anonymous>`, which makes V8 name the stack frame
  `<anonymous>.getData`. It reports `ous>.getData` before the fix.
- `yarn test ReactFlightAsyncDebugInfo --runInBand` (21 passed)
- `yarn test ReactFlight --runInBand` (437 passed, 3 pre-existing
  ReactFlightDOMEdge SharedArrayBuffer failures that also fail on main)
- `yarn linc`
- `node scripts/prettier/index.js check-changed`
@meta-cla meta-cla Bot added the CLA Signed label Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Comparing: 99c106c...6dbf84b

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 7.35 kB 7.35 kB = 1.96 kB 1.96 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 626.10 kB 626.10 kB = 110.63 kB 110.63 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 7.36 kB 7.36 kB = 1.96 kB 1.96 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 697.31 kB 697.31 kB = 122.07 kB 122.07 kB
facebook-www/ReactDOM-prod.classic.js = 715.35 kB 715.35 kB = 125.14 kB 125.14 kB
facebook-www/ReactDOM-prod.modern.js = 705.66 kB 705.66 kB = 123.57 kB 123.57 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by sizebot against 6dbf84b

@eps1lon eps1lon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you!

@eps1lon
eps1lon merged commit 63d39af into react:main Oct 19, 2026
239 checks passed
eps1lon pushed a commit to vercel/next.js that referenced this pull request Oct 20, 2026
[diff
react/react@99c106c4...ba39b32a](react/react@99c106c...ba39b32)

<details>
<summary>React upstream changes</summary>

- react/react#37853
- react/react#37856
- react/react#37855

</details>

---------

Co-authored-by: next-js-bot[bot] <279046576+next-js-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants