You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Component.render() is silently swallowing errors with no console output #4199
A piece of code in my render function is error-ing. A simple try/catch was able to capture and display the error, but without it React just silently proceeds by returning null in the render function and no error which makes it very difficult to find. Basically if the error happens, render fails silently and displays an empty component.
I am coming up with a JSFiddle to reprod in a simpler case for you to debug.
this is still a thing... I keep debugging for long periods of time because some errors react won't put into the console.log.
Here's the most recent example:
I have tried to access this.setState inside a function that, itself, should have been bound to "this". When I called this.setState inside the function it failed, resulting in the whole component and all subsequent components to fail rendering, yet no errors where being printed to the console. After I have figured the error out and have, just out of curiosity, wrapped this.setState with a try catch I got this:
There is most likely nothing to fix in React. React is not catching any errors. The issue you're seeing is most likely due to your call to setState being inside a Promise callback. When exception is thrown, your catch() handler might be swallowing it. Alternatively it may be possible that you don't have a catch() handler, and Promise rejection stays unhandled, but your Promise polyfill might not log unhandled rejection. In this case I recommend changing the Promise polyfill.
If you're sure it's a problem with React then please help us by providing a case reproducing it. Thanks!
Reacted by Amr Abdulrahman, Boyang, Amgad Naiem and Alper Akyol
Ok, this was on me. I have found no promises anywhere in my project but after I have completely overhauled my webpack configuration (and also my webpack dev server configuration) everything (including errors) showed up as expected. So, still not really sure where the issue was but obviously it was somewhere in my webpack configs.
@hurrtz Currently experiencing this same silent errors and I suspect it might be our webpack config too. Do you by any chance have your the before and after webpack config files? Or care to share what changed in webpack?
Activity
sophiebits commentedon Jun 23, 2015
See #2912. Happy to reopen if a simple case shows React is doing something wrong.
hurrtz commentedon Sep 11, 2016
Hey guys,
this is still a thing... I keep debugging for long periods of time because some errors react won't put into the console.log.
Here's the most recent example:
I have tried to access this.setState inside a function that, itself, should have been bound to "this". When I called this.setState inside the function it failed, resulting in the whole component and all subsequent components to fail rendering, yet no errors where being printed to the console. After I have figured the error out and have, just out of curiosity, wrapped this.setState with a try catch I got this:
Is there any way to enable these errors in dev-mode without manually wrapping code in try-catch blocks?
aweary commentedon Sep 11, 2016
@hurrtz could you can share a minimal test case reproducing the issue? You can use https://jsfiddle.net/reactjs/69z2wepo/ as starting point.
gaearon commentedon Sep 11, 2016
@hurrtz
There is most likely nothing to fix in React. React is not catching any errors. The issue you're seeing is most likely due to your call to setState being inside a Promise callback. When exception is thrown, your catch() handler might be swallowing it. Alternatively it may be possible that you don't have a catch() handler, and Promise rejection stays unhandled, but your Promise polyfill might not log unhandled rejection. In this case I recommend changing the Promise polyfill.
If you're sure it's a problem with React then please help us by providing a case reproducing it. Thanks!
hurrtz commentedon Oct 14, 2016
Ok, this was on me. I have found no promises anywhere in my project but after I have completely overhauled my webpack configuration (and also my webpack dev server configuration) everything (including errors) showed up as expected. So, still not really sure where the issue was but obviously it was somewhere in my webpack configs.
samit4me commentedon Nov 6, 2016
@hurrtz Currently experiencing this same silent errors and I suspect it might be our webpack config too. Do you by any chance have your the before and after webpack config files? Or care to share what changed in webpack?
samit4me commentedon Nov 8, 2016
Turn out it was a Promise eating the error. In the flux store triggered by a parent.