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

"An unexpected error has occurred" on replicated server #3299

Closed
sethsamuel opened this issue Nov 16, 2017 · 4 comments
Closed

"An unexpected error has occurred" on replicated server #3299

sethsamuel opened this issue Nov 16, 2017 · 4 comments

Comments

@sethsamuel
Copy link

sethsamuel commented Nov 16, 2017

  • [ x] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

I should be able to run a nextjs app on multiple server replicas without errors occurring.

Current Behavior

Trying to run next 4.1.4 in a kubernetes cluster and about half of the requests to the server result in "An unexpected error has occurred." If the request is made client-side, the only error in the console is 500 - Internal Server Error. undefined. There is no server log with more error details.

This does not appear to be happening with a 3.x app run in a similar context.

Steps to Reproduce (for bugs)

  1. Create next.js 4 app
  2. Run in kubernetes cluster
  3. Load page repeatedly

Context

I've already implemented the build-stats hack here #2978 (comment) to have consistent build ids across the replicas. That resolved that set of errors but now stuck with undebuggable errors.

ETA: This appears to still be build id related. The error that's thrown has buildIdMismatched: true even through both replicas have identical .next/build-stats.json files.

Your Environment

Tech Version
next 4.1.4
node 8
OS CoreOS
browser Chrome/Firefox
etc
@sethsamuel
Copy link
Author

Turns out I needed to also override .next/BUILD_ID to have the same consistent value.

@davidqhr
Copy link

@sethsamuel , I met the same issue here. But What to do when process a rolling update. The new pods and old pods have different BUILD_IDS.

@sethsamuel
Copy link
Author

Without sticky requests I think it's impossible to avoid 500s during a rolling update. It would help if next fell back to server side rendering on mismatched build ids, rather than 500ing, but not sure how hard that would be to implement.

@davidqhr
Copy link

The only way I found is use CDN to cache static files. CDN service like cloudflare knows how to handle two version of the same file.This approach is not perfect, but can reduce many 500 errors.

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

No branches or pull requests

2 participants