Skip to content

Fix inspectElement crash and show numeric IDs for unresolved components#47

Merged
piotrski merged 4 commits into
callstackincubator:mainfrom
xilin:fix/inspect-hooks-dehydrated-format-and-numeric-ids
Apr 1, 2026
Merged

Fix inspectElement crash and show numeric IDs for unresolved components#47
piotrski merged 4 commits into
callstackincubator:mainfrom
xilin:fix/inspect-hooks-dehydrated-format-and-numeric-ids

Conversation

@xilin
Copy link
Copy Markdown
Contributor

@xilin xilin commented Mar 31, 2026

Two fixes:

  1. Handle dehydrated hooks format in inspectElement response.
    React DevTools backend may send hooks as a dehydrated object
    { data: [...], cleaned: [...], unserializable: [...] } instead of
    a plain array. parseHooks() called .map() on this object, crashing
    with "hooks.map is not a function". This caused get-component to
    silently time out for ALL components (the crash happened inside
    handleInspectedElement, swallowing the resolved promise).

    Fix: add extractHooksArray() to handle both formats.

  2. Show numeric fiber ID when @c label is unresolved in find results.
    Components deep in the tree (e.g., 3000+ components in a React
    Native app) don't get @c labels assigned because getTree() traversal
    stops early. find returns @c? which can't be used with get-component.

    Fix: output @c?(id:667) so users can pass the numeric ID directly.

xilin added 2 commits March 31, 2026 23:15
   React DevTools backend may send hooks as a dehydrated object
   { data: [...], cleaned: [...], unserializable: [...] } instead of
   a plain array. parseHooks() called .map() on this object, crashing
   with "hooks.map is not a function". This caused get-component to
   silently time out for ALL components (the crash happened inside
   handleInspectedElement, swallowing the resolved promise).

Fix: add extractHooksArray() to handle both formats.
   Components deep in the tree (e.g., 3000+ components in a React
   Native app) don't get @c labels assigned because getTree() traversal
   stops early. find returns @c? which can't be used with get-component.

Fix: output @c?(id:667) so users can pass the numeric ID directly.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 31, 2026

🦋 Changeset detected

Latest commit: 8d68fcc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
agent-react-devtools Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

find results show @c?(id:667) for components outside the labeled tree
range, but resolveId treated anything starting with @c as a label map
lookup — always returning undefined for this format.

Add a regex match for @c?(id:N) before the generic @c branch so these
IDs can be passed directly to get-component.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@piotrski piotrski left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @xilin, great catches on both of these.

One small thing I noticed the @c?(id:667) display format is the right call, but resolveId() treats anything starting with @c as a label map lookup, which means passing it to get component would always silently fail. I went ahead and pushed a fix along with a changeset.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@piotrski piotrski force-pushed the fix/inspect-hooks-dehydrated-format-and-numeric-ids branch from 30b76eb to 8d68fcc Compare March 31, 2026 17:26
@xilin
Copy link
Copy Markdown
Contributor Author

xilin commented Apr 1, 2026

Thanks for the contribution @xilin, great catches on both of these.

One small thing I noticed the @c?(id:667) display format is the right call, but resolveId() treats anything starting with @c as a label map lookup, which means passing it to get component would always silently fail. I went ahead and pushed a fix along with a changeset.

Sounds good, thanks again for creating this great tool!

@piotrski piotrski merged commit 90d1344 into callstackincubator:main Apr 1, 2026
4 checks passed
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