Skip to content

[compiler] Keep render counters registered across updates - #38262

Open
chengchuu wants to merge 4 commits into
react:mainfrom
chengchuu:fix/compiler-render-counter-registration
Open

chengchuu wants to merge 4 commits into
react:mainfrom
chengchuu:fix/compiler-render-counter-registration

Conversation

@chengchuu

Copy link
Copy Markdown
Contributor

Summary

Fixes #38261

useRenderCounter loses its registry entry after the first update or Strict Mode effect replay. Cleanup removes the counter, but setup only registers newly created counters.

Keep counters registered across updates and Strict Mode effect replays, preserving counts when name changes. Delete each registry entry only after its last counter is removed.

How did you test this change?

Added seven regression tests covering mount, repeated updates, Strict Mode effect replay, consecutive name changes, shared names, unmount, and clearing counts.

  1. 4fb03b6828 — Six tests failed before the fix.
  2. 43f040e7e2 — All seven tests passed with the fix.

From the repository root:

nvm use
cd compiler
yarn install --frozen-lockfile
yarn jest --config packages/babel-plugin-react-compiler/scripts/jest/main.config.js --runInBand
yarn snap:build
yarn snap
yarn snap --rust

All listed tests passed with the fix.

Six tests intentionally fail on the unfixed runtime; the initial registration test passes.
@meta-cla meta-cla Bot added the CLA Signed label Nov 16, 2026
@chengchuu
chengchuu force-pushed the fix/compiler-render-counter-registration branch from 4a48402 to 43f040e Compare November 16, 2026 14:30
@chengchuu

This comment was marked as resolved.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Compiler Bug]: Render counters unregister after the first update

1 participant