-
Notifications
You must be signed in to change notification settings - Fork 47.3k
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
DevTools does not eagerly patch console for RN #17097
DevTools does not eagerly patch console for RN #17097
Conversation
Previously, the DevTools backend eagerly patched the console (to append component stacks to warnings and errors) even if no DevTools frontend was running. I did this because I thought the components stacks would be very helpful, and a lot of RN developers don't even run the DevTools UI to otherwise get them. (Also there would be no other way to get them for errors logged during mount.) Unfortunately this has the downside of affecting the source code line shown for the errors/warnings in debugger tooling, which seemed like a net loss in hindsight- so I'm removing the eager patching. This should not affect the browser/DOM extension.
Huh, that's not at all what I thought the behavior was! What do you mean by this? I was looking at this screenshot: It has real filenames for all logs except the The thing I'd like to see fixed is the regular |
To clarify, the relevant part is the red rectangle on the blurred screenshot. |
Ahh, I see. I misunderstood this to be about the component stack logs, but it seems this is actually about the fact that DevTools patches Hmm...maybe we should separate those. |
Ohh I didn’t realize that’s what it is. Yeah. I think it’s OK to keep hijacking warn/error but probably not log by default. |
Silly question. Can’t we only override console log when we re evaluate Hooks? And restore it right after. |
Yeah, maybe that override could be deferred until the first time a component was actually inspected (which would never happen unless someone was actually using the DevTools frontend). So then the open question would be if we wanted to still keep eagerly overriding |
Duh. I'm having trouble remembering my own code. We already do delay patching react/packages/react-devtools-shared/src/backend/renderer.js Lines 2291 to 2313 in 4cb399a
I am confused about the originally reported issue now. |
Previously, the DevTools backend eagerly patched the console (to append "component stacks" to warnings and errors) even if no DevTools frontend was running. I did this because I thought the components stacks would be very helpful, and a lot of RN developers don't even run the DevTools UI to otherwise get them. (Also there would be no other way to get them for errors logged during mount.)
Unfortunately this had the observable effect of changing the source code line shown for the errors/warnings in debugger tooling (where the actual call to the native
console.error
is made) fromYellowBox.js
(the RN override) to the DevToolsbackend.js
script. Some people complained, so this PR removes that default behavior1.This should not affect the browser/DOM extension. I have tested to confirm this in the browser. I tested the change in RN by building the
react-native-core
backend and patching my local version of React Native.Resolves facebook/react-native#26788
1 I'm not sure I understand why the previous behavior (of showing the
YellowBox.js
override location) was preferable to showing the DevTools backend. Neither is the location of the original caller. I've asked for clarification on the RN issue. If we decide to remove the DevTools override though, this is the way to do it.