Skip to content
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

fix[react-devtools]: restore original args when recording errors #30091

Conversation

hoxyq
Copy link
Contributor

@hoxyq hoxyq commented Jun 25, 2024

Summary

When DevTools frontend and backend are connected, we patch console in 2 places:

  • patch(), when renderer is attached to:
    • listen to any errors / warnings emitted
    • append component stack if requested by the user
  • patchForStrictMode(), when React notifies about that the next invocation is about to happed during StrictMode

patchForStrictMode() will always be at the top of the patch stack, because it is called at runtime when React notifies React DevTools, because of this, patch() may receive already modified arguments (with stylings for dimming), we should attempt to restore the original arguments

How did you test this change?

Look at yellow warnings on the element view:

Before After
Screenshot 2024-06-25 at 14 38 26 Screenshot 2024-06-25 at 17 26 23

@hoxyq hoxyq requested a review from vzaidman June 25, 2024 17:10
Copy link

vercel bot commented Jun 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 25, 2024 6:09pm

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Jun 25, 2024
@hoxyq hoxyq force-pushed the react-devtools/restore-original-args-when-recording-errors branch 2 times, most recently from 160aea7 to 238c154 Compare June 25, 2024 17:13
@hoxyq hoxyq force-pushed the react-devtools/restore-original-args-when-recording-errors branch from 238c154 to 23b6430 Compare June 25, 2024 18:04
@hoxyq hoxyq force-pushed the react-devtools/restore-original-args-when-recording-errors branch from 23b6430 to 1f9ce44 Compare June 25, 2024 18:05
@hoxyq hoxyq merged commit a8b465c into facebook:main Jun 26, 2024
138 checks passed
@hoxyq hoxyq deleted the react-devtools/restore-original-args-when-recording-errors branch June 26, 2024 13:17
hoxyq added a commit that referenced this pull request Jul 3, 2024
## Summary

Full list of changes, mostly fixes:
* chore[react-devtools/renderer]: dont show strict mode warning for prod
renderer builds ([hoxyq](https://github.com/hoxyq) in
[#30158](#30158))
* chore[react-devtools/ui]: fix strict mode badge styles
([hoxyq](https://github.com/hoxyq) in
[#30159](#30159))
* fix[react-devtools]: restore original args when recording errors
([hoxyq](https://github.com/hoxyq) in
[#30091](#30091))
* Read constructor name more carefully
([LoganDark](https://github.com/LoganDark) in
[#29954](#29954))
* refactor[react-devtools/extensions]: dont debounce cleanup logic on
navigation ([hoxyq](https://github.com/hoxyq) in
[#30027](#30027))
* lint: enable reportUnusedDisableDirectives and remove unused
suppressions ([kassens](https://github.com/kassens) in
[#28721](#28721))
* fix[react-devtools/extensions]: propagate globals from env
([hoxyq](https://github.com/hoxyq) in
[#29963](#29963))
* refactor[react-devtools/tests]: use registered marks instead of
cleared in tests ([hoxyq](https://github.com/hoxyq) in
[#29929](#29929))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants