Skip to content

react-router eats stack traces in willTransitionTo (and subsequently component*Mount) #946

@AndrewRayCode

Description

@AndrewRayCode

A frustrating behavior of the router:

https://github.com/rackt/react-router/blob/master/modules/Transition.js#L60

If you have any errors in your component mounting / instantiating, they are eaten by the router. All you'll get in the console is something like "Undefined is not a function" but no stack trace. I believe this is because the mount* functions get called synchronously, so when that code calls callback it triggers the React land component stuff, and any errors are caught by the try catch. The error eventually gets thrown here:

https://github.com/rackt/react-router/blob/e0a15ebc81d76119935fef27e0ab7d7b024b98fd/modules/createRouter.js#L303

This makes it very hard to debug errors in component instantiation.

This can be reproduced very simply by making a component with a willTransitionTo that has a runtime error either in the willTransitionTo or in the render.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions