Skip to content

Profiling hooks compatibility#138

Merged
kentcdodds merged 5 commits intomainfrom
cursor/profiling-hooks-compatibility-e1db
Feb 24, 2026
Merged

Profiling hooks compatibility#138
kentcdodds merged 5 commits intomainfrom
cursor/profiling-hooks-compatibility-e1db

Conversation

@kentcdodds
Copy link
Member

@kentcdodds kentcdodds commented Feb 24, 2026

Update performance module tests for React 19 compatibility by replacing injectProfilingHooks with a onCommitFiberRoot fallback.

React 19 removed internals.injectProfilingHooks, causing all performance module tests to fail with a TypeError. This PR introduces a compatibility layer that uses onCommitFiberRoot and fiber PerformedWork data when injectProfilingHooks is unavailable, ensuring tests function correctly on modern React versions while maintaining support for older versions. The counting logic was also refined to prevent overcounting due to memo wrappers.


Open in Web Open in Cursor 


Note

Medium Risk
Touches test/profiling infrastructure and relies on React fiber internals/flags, so it may be brittle across React versions and could change which components are counted as “rendered.”

Overview
Improves the render-counting helper used by rerender exercises to work across React versions by conditionally using internals.injectProfilingHooks when available and otherwise falling back to onCommitFiberRoot traversal.

The fallback inspects committed fibers (filtering to user component tags and PerformedWork flag) and derives stable component display names to avoid miscounting with memo/forwardRef wrappers; the same logic is inlined into several memoized.test.ts files and implemented in shared/get-component-calls.tsx, with proper setup/teardown via try/finally.

Written by Cursor Bugbot for commit bcb2171. This will update automatically on new commits. Configure here.

cursoragent and others added 2 commits February 24, 2026 21:59
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@cursor
Copy link

cursor bot commented Feb 24, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@kentcdodds kentcdodds marked this pull request as ready for review February 24, 2026 22:54
@cursor

This comment has been minimized.

@cursor

This comment has been minimized.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is ON. A Cloud Agent has been kicked off to fix the reported issue.

@cursor
Copy link

cursor bot commented Feb 24, 2026

Bugbot Autofix prepared fixes for 1 of the 1 bugs found in the latest run.

  • ✅ Fixed: Fallback path silently drops anonymous components in test files
    • Updated the fallback collection path in all memoized tests to push anonymous components consistently with profiling hooks behavior.

@kentcdodds kentcdodds merged commit ae4f41b into main Feb 24, 2026
5 checks passed
@kentcdodds kentcdodds deleted the cursor/profiling-hooks-compatibility-e1db branch February 24, 2026 23:35
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.

2 participants