Replies: 12 comments 6 replies
-
I just did a quick test, and can confirm, the chunk names are not the same between builds. All I did is build once locally, delete the .next folder, then build again. The results are different chunk names:
Many of the build artifacts do have the same names - it seems to be these app chunks that don't get the same (deterministic) hashes. |
Beta Was this translation helpful? Give feedback.
-
Hey, We have exactly the same problem here ! What is the real utility of the Next.js config generateBuildId ... ? |
Beta Was this translation helpful? Give feedback.
-
I tried to create an issue, but it requires a bunch of work since you have to create a reproduction repo. This is easy to understand, and should be in a unit test somewhere. |
Beta Was this translation helpful? Give feedback.
-
I'd like to concur on this issue, The codebase I'm working with is quite complex so there is likely a lot of moving parts causing this discrepancy, however I would like to note: I have a pretty simple layout file that is shared for a few pages, seen with this code: // layout-component.tsx
import Script from 'next/script';
import Footer from './footer';
import Header from './header';
import Main from './main';
export default function DefaultLayout({
children,
}: Readonly<{
children?: React.ReactNode;
}>) {
return (
<>
{process.env.NODE_ENV === 'production' && <Script src="/analytics.js" />}
<Header />
<Main>{children}</Main>
<Footer />
</>
);
} With that code in that particular file, and a However, simply removing the // layout-component.tsx, modified to remove <Script />.
import Footer from './footer';
import Header from './header';
import Main from './main';
export default function DefaultLayout({
children,
}: Readonly<{
children?: React.ReactNode;
}>) {
return (
<>
<Header />
<Main>{children}</Main>
<Footer />
</>
);
} Now, the Completely confounded as to why such a change would cause this issue, especially with a Build ID. Being that we are building to a couple different load balancers, this is a very irritating issue. I had previously thought this non-deterministic issue was potentially caused by more complex |
Beta Was this translation helpful? Give feedback.
-
For what it's worth, what we do is docker build which runs the |
Beta Was this translation helpful? Give feedback.
-
This is a bit confounding to me as well. I'm using a consistent |
Beta Was this translation helpful? Give feedback.
-
I guess someone is going to have to make a reproduction repro, and file a ticket, even though there's more than enough information on this thread to see the problem... @JohnRPB That used to work as expected. Now we get variable chunk names. There are workarounds available (described above), but none of that should be necessary. |
Beta Was this translation helpful? Give feedback.
-
hey @CaptainN @JohnRPB have u found a solution ? having the same issue where the server chunks are different between my local env and CI/CD |
Beta Was this translation helpful? Give feedback.
-
is there any update ? |
Beta Was this translation helpful? Give feedback.
-
Adding my 2c to this - This is a blocker especially given source maps are either all or nothing. If you want a public build without source maps, and a separate source-mapped build for external monitoring (sentry/datadog etc), the chunk names are going to be different. In this related discussion #7579 (comment) there are only half-solutions which involve stripping out sourcemaps from the deployed build which seems to cause 404s in some browsers. |
Beta Was this translation helpful? Give feedback.
-
I think Vercel is intentionally not solving this so that we use their platform :D |
Beta Was this translation helpful? Give feedback.
-
Summary
I have a site that we have been running with 2 horizontally scaled pods, which uses
generateBuildId
to return the git hash of the current commit for reliable scaling. I thought that meant the chunk hashes would be deterministically generated - that is, they'd be the same between pods (which are built at startup in the runtime environment, since static generation occurs at build time, and the necessary services are not available in the build environment).This worked for a long time, but we just had a site meltdown because the chunk hash names didn't match, and when balancing occured, it was causing errors in loading. The solution was to scale back down to one instance for the time being. I did confirm by inspecting the build artifacts that .next/BUILD_ID matched between the pods, but the chunk names which were erroring did not.
Is BUILD_ID not intended to be used this way?
Additional information
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions