Skip to content

fix(react): preserve render profiles for all component names - #2518

Open
kanishksingh01 wants to merge 1 commit into
vercel-labs:mainfrom
kanishksingh01:fix/react-profiler-component-names
Open

kanishksingh01 wants to merge 1 commit into
vercel-labs:mainfrom
kanishksingh01:fix/react-profiler-component-names

Conversation

@kanishksingh01

Copy link
Copy Markdown

A React component named constructor, toString, hasOwnProperty, or __proto__ can make react renders silently drop the rest of a commit. The profiler indexes a plain object by component name, mistakes an inherited property for an initialized record, and throws at _instances.has. The commit hook catches the exception and returns an incomplete profile.

Use a null-prototype dictionary for component records. Add dependency-free Node regression tests that execute the embedded start/stop scripts and verify that both the affected component and its following sibling are recorded. Run these tests in the existing Node CI job.

With a component whose displayName is constructor followed by a normal sibling, both component bodies execute once. Before this change the profile reports zero renders; after the change it reports two.

Validation

  • pnpm run test:react-renders: 4 passed; all 4 fail against unchanged main.
  • pnpm run test:launcher: 4 passed.
  • cargo test --locked --manifest-path cli/Cargo.toml native::react -- --test-threads=1: 2 passed.
  • cargo fmt --manifest-path cli/Cargo.toml -- --check: passed.
  • cargo clippy --locked --manifest-path cli/Cargo.toml -- -D warnings: passed.
  • Additional local checks using React test renderer 18.3.1 and 19.2.0 reproduce the missing records before the fix and capture both components afterward.

The full Rust suite was not successfully validated locally: an optimized build was killed, and a broader development-profile run showed failures outside the React profiler before being interrupted during repeated browser-launch retries. No Chrome end-to-end run was performed.

Found while investigating #2508. This fixes the component-name collision in the accumulator; #2512 addresses the separate bailout-counting problem.

AI assistance: Codex helped investigate, implement, and validate this change.

RENDERS_INIT stores entries in a plain object, so inherited properties are mistaken for existing component records. Use a dictionary without a prototype and execute the embedded scripts in regression tests.
@vercel

vercel Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

@kanishksingh01 is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

1 participant