Skip to content

nondeterministic chunk names when using plugin #277

Description

@khalilsarwari

Environment

What version are you running?

I believe version 1.20.0 of the plugin, 7.38 of sentry, 13.0.5 of nextjs.

"node_modules/@sentry/webpack-plugin": {
"resolved": "https://registry.npmjs.org/@sentry/webpack-plugin/-/webpack-plugin-1.20.0.tgz",
"@sentry/cli": "^1.74.6",

"@sentry/nextjs": {
"resolved": "https://registry.npmjs.org/@sentry/nextjs/-/nextjs-7.38.0.tgz",
"@sentry/core": "7.38.0",
"@sentry/integrations": "7.38.0",
"@sentry/node": "7.38.0",
"@sentry/react": "7.38.0",
"@sentry/tracing": "7.38.0",
"@sentry/types": "7.38.0",
"@sentry/utils": "7.38.0",
"@sentry/webpack-plugin": "1.20.0",

next version: 13.0.5

Here is an excerpt of my next.config.js (intentionally using as close to empty options as possible to reduce chance of error):

const moduleExports = 
   {
    reactStrictMode: true,
    experimental: {
      appDir: true,
      }
      ...
    sentry: {
    }
 };

const sentryWebpackPluginOptions = {
silent: true
};

module.exports = withSentryConfig(moduleExports, sentryWebpackPluginOptions);

Steps to Reproduce

  1. rm -rf .next/ && SENTRY_RELEASE=asdfasf npm run build
  2. ls .next/static/chunks/
  3. saw that webpack-95ee68f5578f47f6.js changed to webpack-ca75b5dd44d18fda.js if I rerun from step 1.

Expected Result

The name of the chunk should have stayed the same, since none of the configuration or files changed.
If I remove the plugin by changing:

module.exports = withSentryConfig(moduleExports, sentryWebpackPluginOptions)

to

module.exports = moduleExports

the chunk name does indeed stay the same. This issue only happens with the webpack chunk, not with main or app chunks or any of the others.

Actual Result

The name of the webpack chunk changes from run to run; it is fine if it changes when adding/removing the plugin.
Once the plugin is added though, it shouldn't be changing from run to run when there are no other file changes being made.

Any ideas why this is happening? I am not sure what the link is here, but it is messing up production deployments since the webpack chunk file goes by a different name on each production instance (the same app is being npm run build separately on each instance), resulting in 404 errors depending on how the load balancer directs the requests.
(like request to _next/static/chunks/webpack-d95ad6f27677beeb.js -> 404 error)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status
    Waiting for: Community

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions