react: [DevTools Bug]: Warnings are too "loud", mislabeled and make console difficult to use
Website or app
https://codesandbox.io/s/purple-moon-ts7xzs?file=/src/App.js
Repro steps
It’s not causing this in the codesandbox probably due to some flag missing, but locally in dev I’ve been getting the following when a stray prop is passed to a dom elem as an attribute (NB this output is truncated, this isn’t even the whole message):

Problems with the current logging approach
- This floods the console and pushes all other messages out of screen, making debugging difficult. This is the main issue.
- The severity/“loudness” of this log message is out of proportion to the issue. This is a fairly minor issue as it typically does not actually break anything, yet this log drowns out actual issues that I need to see more urgently
- This issue’s importance is being misclassified & the wrong logging API used:
console.erroris being misused to log a warning. The purpose of different log levels is to allow the consumer (developer) to enable or disable logging of less important messages depending on their needs. Putting warnings in the “error” stream takes this control away from developers. When I am cleaning up upgrade issues, minor bugs etc. I will turn on warnings and see this, but when I’m trying to figure out why my GQL endpoints are erroring, I should be able to turn this off.
Ask
My goal is to stop this effectively “breaking” the error console, i.e. making it unusable by flooding it with messages. Possible approaches:
- move these warnings to console.warn, putting control back in the developer/consumer’s hands
- flag to disable the stack traces so messages aren’t so enormous
- use console.groupCollapsed to collapse these, so the stack is there but doesn’t flood the console
FAQ
Why don’t you just fix the errors? If you fix the errors, this isn’t an issue. The solution is fix the errors.
I don’t mean to brag, but I work on applications with lots of errors. I truly wish I could fix every single one, but I must pick my battles and this often means letting smaller issues slide in order to focus on bigger ones. Furthermore, when working on a shared application, it can be out of your power to fix all the errors. There are several reasonable reasons why someone would want to work on their application and ignore certain errors, at least temporarily.
In any event, “this is a valid error message so why should it be quieter” doesn’t address the question of proportionality. Should a warning like this overtake the whole console? Should it use window.alert? Should it bail out and crash the whole application? It’s clear that these approaches to alerting the developer/consumer to an issue are not proportional with the severity of the issue itself, and these more drastic approaches would be inappropriate, even if they “draw the developer/user’s attention to the issue” as this clearly does. Not every issue is p0 which is why we have log levels, and in this context different log streams (info, warning, and error).
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
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 21
- Comments: 18 (1 by maintainers)
@Sequoia What makes the error messages so long is not the error message itself! it is the error stack which means you have a lot of nested components! This also explains why in your example here you only see a smaller error message as there is only 2 component!
Also I really disagree with this comment. Yes, in practice it would be nice to not have a lot of nested components, but out here in the real world this is never the case. For any reasonably complex React app (which many of us work on at day jobs), there’s no getting around a deep component hierarchy.
@AhmedIbrahim336 Thank you for the additional info. My complaint still stands: even with many nested components warning should not be logged as errors & they should not make the console unusable.
Having deeply nested component structures like this is not uncommon in large production React apps. Mine is not an edge case.
Another example of this issue:
What makes it even worse is for some reason I cannot collapse this message. Attempting to collapse the error message does nothing.
React is breaking my console. ☹️ Please fix this. Not everything is a five-alarm error, and even those things that are should not make the console unusable like this.
Also is a PR welcome to improve this situation? As a first step, I’d love to have a chat with any maintainer here and figure out what acceptable solutions to this would be accepted. I don’t know how to summon a maintainer though!
Some options:
Are there any updates on this?
@IvanD4RE I evolved your solution a bit, and decided to stick with
console.errorso that the errors would show up by default in the console. However, I include some hidden text in the error so you can filter out the errors with-ReactDOMWarningin the devtools console filter section.As long as this issue is open, this code snippet should at least be a quality of life improvement, and provide a bit of filtering control:
Doesn’t seem like a priority, it’s been 2.5 years–patching is probably the best thing here unless someone notices this ticket finally.
Why can’t we just show Warning as a warning and not an error? This makes it hard to look out for actual errors in the code