-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Console log shows the wrong destination file #22257
Comments
Can you try clicking the arrow to the left of the message? It should expand the full stack which gives you precise location of every frame including the one you’re looking for. Also please show the screenshot of your DevTools settings. |
@ |
@gaearon sry, it looks like i have a wrong devtools setting,thank you for you help |
Hey @gaearon, we seem to also be getting this issue on regular console logs (sourcemaps mapping to react_devtools_backend.js:4049). When the react devtools extension is disabled, sourcemaps show correctly. Webpack devtool is set to 'eval-source-map'. This seems to have happened quite recently as I don't recall seeing this before. Let me know if you need me to provide any other info. Left: incognito with react devtools disabled, Right: with react devtools enabled |
Not sure if anything changed here but reopening just in case. |
Chiming in here to confirm that this reported behavior is intentional– although I understand the confusion or annoyance. 😦 The "problem"As of the version 18 release, DevTools always overrides the native console to either dim or suppress The major unfortunate drawback of this overriding is that it changes the location shown by the browser's console as reported in this issue. I requested better tooling support from browsers a couple of years ago because of this, but there hasn't been any action unfortunately: whatwg/console#163 There is a related tc39 proposal but I don't think it has made any progress since then. A possible solutionOne possible change we could look into making on the DevTools side to improve this default experience is to only patch console methods during Right now the way this works is that DevTools eagerly patches the console APIs, and asks React to check if cc @lunaruan |
Perhaps a setting could be added to devtools to opt in to this new behaviour (or opt out)? Atleast till theres a way to fix both? Tbh i had no idea of the double logging issue or maybe had just never noticed it, and I would assume others would be in the same boat. The source map line change however is definitely noticeable and arguably a much more annoying issue (imo) |
Yes, we understand why the issue is annoying and will look into some way to resolve it. |
This is awesome. I browsed the issue list, looking just for this, saw it as the first issue, subscribed to it while ago, and now saw the latest reply from @gaearon. |
I've found a workaround using |
For what it's worth, I've found that by doing things like this [example below], it allows you to override the console with a prefixer while retaining the original stack trace. Not sure if that could be of any relevant help here, but I'm using it in a project for a custom logger, because I found that most logging overrides screw with the stack trace.
|
@jzombie That's a nice tip, but I don't think that offers a way for us to do anything more than inject a static parameter, does it? (I don't think it offers a way to run code, like we're doing in this case.) |
@bvaughn I've only used it to inject a static parameter, but perhaps it could run some code with a bit of fiddling. |
i.e. maybe if you used some sort of object property getter to render the string, and ran the code inside the getter... ? |
If you have any example code/idea you could share, we'd be happy to take a look. 😁 I think a getter would be evaluated at the time you define the |
I tried a couple of different approaches because I was really hoping it would work, and couldn't get beyond the initial value. I'd love to pursue this, this afternoon, but my job would probably not be happy about it, because it's completely unrelated to what I'm supposed to be working on. |
As a temporary workaround for folks affected by this, you might try adding the |
In Chrome, a workaround would be adding the script that overrides the console to the "ignore list" (right-click on the script in dev-tools and add to ignore list). It has some drawbacks, because "ignore list" does a little more than just that, but it works nicely for me for now. |
Any updates on this issue? |
@bvaughn I experimented a little and this is the closest I could get to make something work, where each call to console.log would call alert() with a new index, while retaining the original stack trace. Maybe it could be useful, or maybe not.
(The "inherit window console" thing is not used, but was just seeing if it could be used like this w/o error.) |
One more example showing the console log message, itself, changing per call.
|
@JuraJuki If there were updates on this issue, they would be… on this issue. Please refrain from comments like this — they create notification noise for other people and don’t bring the conversation forward. There’s ongoing work on this. When it’s done we’ll close the issue. |
Another option to work around this without disabling the backend is to |
I find it really ironic that the very same people who created this amazing library, and then also make the underlying functionality which drive hooks, can't wrap the browser console and not lose the stack trace. Perhaps, just don't wrap the console at all, or find a library that does it and use it instead? |
The solution described above: Was released yesterday with DevTools version 4.19.0: |
If you agree that this is an issue when it happens all of the time, why would you change it so that it only happens some of the time? |
@guncha Your comment is missing some important context:
|
Any ETA for 4.19. (or 4.19.1.) landing to the Chrome web store? |
No. I have no insight into Chrome's review process. |
@bvaughn that's understandable, no worries. Thanks for your hard work, React Dev Tools is an invaluable tool ❤️ |
4.19.0 is finally through review which unblocks 4.19.1 from being submitted. (Not sure how long it will take them to approve it.) I'm on PTO today b'c it's my birthday but I've asked if someone else on the team would submit it. |
still happens in version |
What exactly "still happens"? This is not a helpful report because we don't know which part you're referring to. I have verified that the extension does not clobber the log location for the first render. It does clobber the location for the second render in React 18, but that's expected. Hopefully the first location should always be enough. I am going to lock this issue to avoid confusion. The original problem has been resolved. If you see a problem, please file a new issue. |
in my browser console, log info go wrong, it should show real console.log file and correct line info, but now it always show "react_devtools_backend.js: 4049", link to source code show warning:
"Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details.
npx react-codemod rename-unsafe-lifecycles
in your project source folder.Please update the following components: %s"
when i disable react developer tools, it goes correctly. but it goes wrong in 4.18.0 react developer tools. and my colleagues' chrome with react developer tools 4.17.0 is right
Note from maintainers: #22257 (comment) is a workaround until this is fixed in React DevTools
The text was updated successfully, but these errors were encountered: