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

Silently catched error in _app.js getInitialProps #4605

Closed
znarf opened this issue Jun 14, 2018 · 3 comments · Fixed by #4607
Closed

Silently catched error in _app.js getInitialProps #4605

znarf opened this issue Jun 14, 2018 · 3 comments · Fixed by #4607
Assignees

Comments

@znarf
Copy link

znarf commented Jun 14, 2018

Bug report

Describe the bug

When an error is thrown in _app.js getInitialProps on the client side, the error is silently catched and navigation is broken without any error output.

Why it's a problem? As a developer, if you unfortunately generate an error in _app.js getInitialProps, you suddenly have a broken navigation and have no idea what's happening and where to look at.

To Reproduce

  1. Go to https://app-getinitialprops-silent-error-gbvspsorhf.now.sh/
  2. Click on 'Say Hello?'
  3. Not navigating to /hello, no error output.

Expected behavior

Navigating to /hello OR error output.

Source

https://github.com/opencollective/next-issues/tree/master/app-getInitialProps-silent-error

@timneutkens
Copy link
Member

The reason this happens is that when an error is throw in a normal page, we try to render the error page, but the error page also depends on getInitialProps being executed, as you can see here: https://github.com/zeit/next.js/blob/canary/lib/router/router.js#L260-L265

So when an error happens as part of getIntialProps in _app.js we have to catch it again and render the error page.

@znarf
Copy link
Author

znarf commented Jun 14, 2018

Thank you @timneutkens. That was fast!

@timneutkens
Copy link
Member

Thank you very much for the detailed description and reproduction. Makes it way faster to solve issues like this 🙌

@lock lock bot locked as resolved and limited conversation to collaborators Jun 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants