question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

buildManifest 404 causing app failure

See original GitHub issue

Bug report

Describe the bug

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.

To Reproduce

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

Expected behavior

The buildManifest should not 404, and SSG should not hang.

Screenshots

The buildManifest 404: image

The app.json 404: image

Other file 404: image

System information

This is running in a docker image built on top of node:12.2.0-alpine with Next.js version ^9.5.3.

Additional Context

This doesn’t seem to be always happening. The deployment worked totally fine for some time before this began.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:24 (9 by maintainers)

github_iconTop GitHub Comments

8reactions
steedemscommented, Oct 30, 2020

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();
  },
};
2reactions
steedemscommented, Oct 30, 2020

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 🤔

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nextjs 404s on buildManifest across multiple EC2 instances
I've made duplicate deployments on 2 AWS EC2 instances. Each instance also has an Nginx reverse proxy routing port 80 to 3000 (my...
Read more >
Solving “/_next/static/…/pages/***.js 404 Not Found”
Despite the error message detailing which file is missing, it is a fairly nebulous message, as it is not immediately obvious what needs...
Read more >
NextJS redirect not working for static assets - Support
As an example, I see a 404 error when trying to access /_next/static/chunks/main-a054bbf31fb90f6a.js . If there are no redirects in effect, then your...
Read more >
[OutSystems Data Grid] Missing JS Resource causes 404 ...
When trying to load the Data Grid Reactive element on a page, there is a 404 error thrown. This particular error makes it...
Read more >
Nextjs: Cannot find module path build-manifest.json masks an ...
Solution 1. Again, most time this error caused because you have invalid import in Next.js page or components. Solution 2. Removed serverless ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found