-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
Error component rendered 2 times when server rendering in production #2573
Comments
@timneutkens I think I have run into this too. Any update on a fix? Also I am wondering why here https://github.com/zeit/next.js/blob/v3-beta/server/render.js#L223 the error object in production is converted into a simply object containing only a message regardless of the error , thus the client sees this 'err' object. However if my custom error page renders differently depending on the error and say its status code this line masks the true error and makes everything into an unhandled exception. For example if I simply want to render a 404 page for a resource that doesnt exist, in my application code i can throw an Error containing a status code to indicate this and handle that in What is the recommended way to do error handling in next.js with a custom server?
(Edit: actually I just realised in the above case I can set Thanks for any advice! |
@timneutkens, the example is no longer rendering the error page 2 times, did you solved it? Cause I'm seeing this issue as well and, cause you can only see it in prod, I'm having hard times to find the root issue… |
We are also seeing this behavior whenever an un-caught exception is thrown on the server (404's behave as expected). The server renders the error page as expected, but the client also renders the error page. My guess at what is happening, is that the server error is somehow being surfaced to the client, which causes the next handling of client-runtime errors to also be rendered (the one that gets rendered to Does I've created an example that replicates the issue here: https://github.com/kochis/next.js/tree/duplicate-error-example/examples/duplicate-error-pages If there is also a more appropriate way to handle the error to avoid this, any help would be appreciated. |
I believe this was introduced in #1800 And the problem code is here: If there is an error on the server, it's sent to the client through the So it seems like any uncaught exception will render both server & client error pages. I'm not sure what the correct behavior for this should be, but one solution I could think of would be to add |
This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread. |
Expected Behavior
1 error component is rendered
Current Behavior
2 error components are rendered below eachother. 1 through SSR and 1 through client side rendering.
Steps to Reproduce (for bugs)
Context
Issue can be seen here: https://create-next-example-app-olyuogqcxe.now.sh/ (deployment with the above code). Scroll down cause the component itself is screen filling 😅
@harshmaur surfaced this.
Your Environment
The text was updated successfully, but these errors were encountered: