-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
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
move combine reducers sanity check #717 #761
move combine reducers sanity check #717 #761
Conversation
if (sanityError) { | ||
console.error(sanityError.message); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure that this console.error is necessary, the error is thrown very shortly afterwards. And if it is useful, it has just occurred to me that it should probably log error.stack if available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.logs/errors
are a no-no in the library because they are normally uncatchable and noisy (and console
sometimes doesn't exist). A thrown Error
is best because that follows normal JS patterns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think console.error
is inherently bad if it is a sign of an error. React also uses console.error
for propTypes
warnings because they're not really warnings: if you have them, you need to fix them. The nice thing about console.error
is that it prints the stack trace, unlike its friends.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't it disable logging in the production build? Maybe the same thing should happen here. A log isn't bad for devs, but shouldn't make its way to production.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we previously console.error
'd only in development, too.
I think we should hide this console.error
behind the dev flag as well.
Of course, if it's not helpful, it's better to remove it. I'm not sure whether the confusion from error printed twice is bigger than the help from a proper stack trace. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've played with this a bit more using devtools and I don't think the console.error
is helpful. Throwing sanityError
logs the stack trace from where the error was created in combineReducers
, so the two stack traces in the log are actually the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, okay. Then let's remove it! Thanks for checking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, will do.
0354a42
to
df287f3
Compare
Updated to create but not log the error during |
df287f3
to
7bc27de
Compare
Added production check around sanity check (#771) |
It's only OK to check for production env for errors we don't throw. Both environments should throw in the same conditions so error stack traces from production are reproducible in development. Please see #771 (comment). |
Got it. I'll revert back to how it was previously. |
Sure, thanks! |
7bc27de
to
c2bf13c
Compare
move combine reducers sanity check #717
Creates and logs sanity check error during
combineReducers
, but only throws on first invocation. Addresses #717.