Skip to content
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

Throwing components difficult to debug #4982

Closed
neojski opened this issue Sep 26, 2015 · 5 comments
Closed

Throwing components difficult to debug #4982

neojski opened this issue Sep 26, 2015 · 5 comments

Comments

@neojski
Copy link
Contributor

neojski commented Sep 26, 2015

I ran into a similar situation a couple of times: https://jsfiddle.net/gjf6u5of/2/

There is some component that throws for some reason. I got some weird prop and got upset. The stack trace, however, doesn't tell me anything. I doesn't even point me to <Foo />. They only non-react frames are the one with <Fooo /> (the outer-most component) and then with the throwing component.

I would be great if a situation like this was easier to debug. In particular, seeing the state of the parent component would help a lot.

@edvinerikson
Copy link
Contributor

I managed to find the throwing component through the stacktrace + debug it with Chrome devtools.

I'm not quite sure what things that can be done to make this easier to debug, I managed to get the component state/props when I enabled the Pause On Caught Exceptions option (In devtools, inspecting the local scope).
Do you have any suggestions on how to make it easier?

Personally I would prefer that React doesn't do anything with the exceptions (Otherwise it might be even harder to find the source of the exception).

https://jsfiddle.net/69z2wepo/16991/
image
image

@neojski
Copy link
Contributor Author

neojski commented Sep 28, 2015

Yes, but imagine you have 10 components that use Bar (and Bar happens to throw sometimes). You have no idea which one of them passed these weird arguments to Bar.

@sophiebits
Copy link
Collaborator

FWIW if you're truly doing prop validation, this is what propTypes is for and that will automatically show the parent component name.

@colllin
Copy link

colllin commented Dec 7, 2015

+1 for rethinking exception handling. The normal debugging workflow is completely disrupted with the current behavior of swallowing and then re-throwing and/or logging exceptions. What if we just stopped catching exceptions in development mode?

@sophiebits
Copy link
Collaborator

React does not catch any exceptions. If your exceptions are being swallowed then it's something else in your toolchain (likely promises) doing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants