A clear and concise description of what the bug is.
I have a Next.js application which uses getStaticProps and getStaticPaths. It is running inside a docker container with the server target, and I am repeatedly running into a 404 error when trying to fetch the buildManifest.js file, which causes all navigation to break. It also causes direct navigation to pages that don't have a cached version yet to hang forever on the fallback page.
You can see a hanging fallback page here: https://beta.openebooks.us/app/collection/https%3A%2F%2Fqa-circulation.openebooks.us%2FUSOEI%2Fgroups%2F406
You can see the app working, but navigation not working here (because this path was cached before the problem started): https://beta.openebooks.us/app
If the buildManifest file is cached in the browser, for example by visiting the working page and then directly navigating to the not-working page, the not-working page will render correctly, though you will now see 404s on other files, like app.json, etc in the console.
The code producing this behavior is here https://github.com/NYPL-Simplified/circulation-patron-web
The buildManifest should not 404, and SSG should not hang.
The buildManifest 404:

The app.json 404:

Other file 404:

This is running in a docker image built on top of node:12.2.0-alpine with Next.js version ^9.5.3.
This doesn't seem to be always happening. The deployment worked totally fine for some time before this began.
Update: this is not a Next.js issue, but was caused by the load balancer improperly routing traffic to an instance that does not have the necessary file
Next.js should still be able to handle this!
@Timer I did find this documentation on the build-id, which I had not previously seen and am planning to try later today: https://nextjs.org/docs/api-reference/next.config.js/configuring-the-build-id
I will let you know if that solves it
And thanks for your quick reply here!
Hi! I am having the same (similar) issue.
Not always, but often (specially straight after deploying) the app would load but buildManifest would 404 and the navigation would be completely broken. After refreshing a couple (or sometimes several) times, the file would be found and everything would work as expected.
I am trying configuring the build id as suggested and will soon know if it solves the issue 馃 - @kristojorg did that work for you?
In the meanwhile I am thinking, shouldn't such error be kind of louder or somehow handled?
Is there a good way to find out whether files don't load correctly at render time maybe? 馃
Btw I have seen there's been talks about navigation not working in the past and I am now guessing some of those might be related to this. Eg this old issue maybe 馃
@steedems are you running multiple versions of the app behind some kind of load balancer or system like that? That is (I think) the only thing that should cause my issue. I haven't tested the fix yet, but instead got rid of all but one instance.
Will let you know once I have an opportunity to try it with the deterministic buildId and multiple instances
Yes, I have like 2/3 instances behind a load balancer.
I am now using the last commit hash as build id and it _seems_ to have solved the issue 馃
I have deployed a couple of times already and haven't seen it happening again - it wasn't easy to reproduce so I'll wait for some more deploys before celebrating.
Here's how my next.config.js now looks like btw:
const execSync = require("child_process").execSync;
const lastCommitCommand = "git rev-parse HEAD";
module.exports = {
async generateBuildId() {
return execSync(lastCommitCommand).toString().trim();
},
};
I've made a similar change in my next.config.js and I believe it will solve my issue. Will reopen this if the issue comes back at some point
Please leave this open. We've confirmed it's a bug.
Sorry about that... I'm not sure what the bug is though? If you've confirmed this is a bug, should I refrain from running the app behind a load balancer in production until this is closed? Even with the deterministic buildID setting?