-
Notifications
You must be signed in to change notification settings - Fork 48.6k
[DevTools Bug]: Hook parsing fails if a hook uses useSyncExternalStore #27889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I've made a bit more progress investigating this. I believe the cause might be the two calls to react/packages/react-debug-tools/src/ReactDebugHooks.js Lines 265 to 274 in 1d5667a
To try to verify that, I found that just one other hook in that file, react/packages/react-debug-tools/src/ReactDebugHooks.js Lines 284 to 292 in 1d5667a
I modified my test case to use |
hey @hoxyq did you work on this? |
@jamesbvaughan, thanks for reporting this! Will take a look at it in a few days and reply back. |
react/packages/react-debug-tools/src/ReactDebugHooks.js Lines 56 to 82 in 1d5667a
When i was trying to debug this problem i notice that here they didn't call the |
Sorry for a late reply. Yes, this is required for generating stack frames of primitives, so this could be the root cause of why RDT can't find @jamesbvaughan Thanks for providing the repro! Is someone interested in testing this solution against the repro and opening a PR? |
@hoxyq I can try to put together a PR this week. |
I've put put a PR: #28399 |
…28399) <!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request. The three fields below are mandatory. Before submitting a pull request, please make sure the following is done: 1. Fork [the repository](https://github.com/facebook/react) and create your branch from `main`. 2. Run `yarn` in the repository root. 3. If you've fixed a bug or added code that should be tested, add tests! 4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch TestName` is helpful in development. 5. Run `yarn test --prod` to test in the production environment. It supports the same options as `yarn test`. 6. If you need a debugger, run `yarn test --debug --watch TestName`, open `chrome://inspect`, and press "Inspect". 7. Format your code with [prettier](https://github.com/prettier/prettier) (`yarn prettier`). 8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only check changed files. 9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`). 10. If you haven't already, complete the CLA. Learn more about contributing: https://reactjs.org/docs/how-to-contribute.html --> ## Summary <!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? --> This solves the problem of the devtools extension failing to parse hook names for components that make use of `useSyncExternalStore` or `useTransition`. See #27889 ## How did you test this change? <!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. How exactly did you verify that your PR solves the issue you wanted to solve? If you leave this empty, your PR will very likely be closed. --> I tested this against my own codebases and against the example repro project that I linked in #27889. To test, I opened up the Components tab of the dev tools extension, selected a component with hooks that make use of `useSyncExternalStore` or `useTransition`, clicked the "parse hook names" magic wand button, and observed that it now succeeds.
@hoxyq Could you advise when the DevTools Firefox Extension will be updated? This issue affects me and it's good to see that it's been fixed but my browser is stuck on v5.0.0 of the extension from December. |
I've uploaded v5.0.2 to Firefox store a week ago, its still pending review process. |
…acebook#28399) <!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request. The three fields below are mandatory. Before submitting a pull request, please make sure the following is done: 1. Fork [the repository](https://github.com/facebook/react) and create your branch from `main`. 2. Run `yarn` in the repository root. 3. If you've fixed a bug or added code that should be tested, add tests! 4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch TestName` is helpful in development. 5. Run `yarn test --prod` to test in the production environment. It supports the same options as `yarn test`. 6. If you need a debugger, run `yarn test --debug --watch TestName`, open `chrome://inspect`, and press "Inspect". 7. Format your code with [prettier](https://github.com/prettier/prettier) (`yarn prettier`). 8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only check changed files. 9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`). 10. If you haven't already, complete the CLA. Learn more about contributing: https://reactjs.org/docs/how-to-contribute.html --> ## Summary <!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? --> This solves the problem of the devtools extension failing to parse hook names for components that make use of `useSyncExternalStore` or `useTransition`. See facebook#27889 ## How did you test this change? <!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. How exactly did you verify that your PR solves the issue you wanted to solve? If you leave this empty, your PR will very likely be closed. --> I tested this against my own codebases and against the example repro project that I linked in facebook#27889. To test, I opened up the Components tab of the dev tools extension, selected a component with hooks that make use of `useSyncExternalStore` or `useTransition`, clicked the "parse hook names" magic wand button, and observed that it now succeeds.
…28399) <!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request. The three fields below are mandatory. Before submitting a pull request, please make sure the following is done: 1. Fork [the repository](https://github.com/facebook/react) and create your branch from `main`. 2. Run `yarn` in the repository root. 3. If you've fixed a bug or added code that should be tested, add tests! 4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch TestName` is helpful in development. 5. Run `yarn test --prod` to test in the production environment. It supports the same options as `yarn test`. 6. If you need a debugger, run `yarn test --debug --watch TestName`, open `chrome://inspect`, and press "Inspect". 7. Format your code with [prettier](https://github.com/prettier/prettier) (`yarn prettier`). 8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only check changed files. 9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`). 10. If you haven't already, complete the CLA. Learn more about contributing: https://reactjs.org/docs/how-to-contribute.html --> ## Summary <!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? --> This solves the problem of the devtools extension failing to parse hook names for components that make use of `useSyncExternalStore` or `useTransition`. See #27889 ## How did you test this change? <!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. How exactly did you verify that your PR solves the issue you wanted to solve? If you leave this empty, your PR will very likely be closed. --> I tested this against my own codebases and against the example repro project that I linked in #27889. To test, I opened up the Components tab of the dev tools extension, selected a component with hooks that make use of `useSyncExternalStore` or `useTransition`, clicked the "parse hook names" magic wand button, and observed that it now succeeds. DiffTrain build for commit 47beb96.
Uh oh!
There was an error while loading. Please reload this page.
Website or app
https://react-devtools-issue-demo.vercel.app/
Repro steps
Hook name parsing is really helpful when debugging/optimizing large components with lots of hooks, and this issue makes that feature unusable on components whose hooks make use of
useSyncExternalStore
.This is particularly painful for my current work, where nearly all components make use of Zustand stores, which use
useSyncExternalStore
internally.This is the same symptom that folks are hitting in #24980, but I'm not sure whether the cause is the same for everyone there.
How often does this bug happen?
Every time
DevTools package (automated)
No response
DevTools version (automated)
No response
Error message (automated)
No response
Error call stack (automated)
No response
Error component stack (automated)
No response
GitHub query string (automated)
No response
The text was updated successfully, but these errors were encountered: