Skip to content
This repository was archived by the owner on Oct 29, 2026. It is now read-only.
This repository was archived by the owner on Oct 29, 2026. It is now read-only.

sentryWebpackPlugin makes webpack forget content hashes #680

Closed

Description

@josefnorlin

Environment

3.1.2

Steps to Reproduce

  1. Run a production build using Gitlab CI
  2. See that content hashes in dist/static/js/***.bundle.js gets regenerated every time:
  3. Removing, makes it work again:
webpackConfig.plugins.push(
   sentryWebpackPlugin({
      project: 'XXX',
      org: 'XXX',
      release: process.env.VERSION,
      include: './dist',
      dryRun: !!process.env.ANALYZE,
      rewrite: false,
  })
);
  1. Also setting realContentHash to false makes it work, but that might cause other problems:
optimization: {
      realContentHash: false,
 },

Expected Result

Should not change on each rebuild.

Actual Result

New dist/static/js/***.bundle.js files every time. Also tried rewrite: true/false to no avail.

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Feb 19, 2025
  2. Lms24 commented on Feb 19, 2025

    @Lms24
    Member

    Hi, thanks for writing in! Can you please share a minimal reproduction that we can use to investigate this?

    Without a full picture, my best guess would be that our plugin injects something that changes on every build dynamically, for instance the release or debugIds.

    Removing, makes it work again:

    Removing what?

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Feb 19, 2025
  4. moved this to Waiting for: Community in GitHub Issues with 👀 3on Feb 19, 2025
  5. josefnorlin commented on Feb 19, 2025

    @josefnorlin
    Author

    Here's a minimal reproduction:
    https://github.com/josefnorlin/sentry-webpack-repro

    And run it on a Gitlab CI/CD process (since this is no problem running locally):

    1. Run it first like it is in Gitlab and download the build artifact.
    2. Note the file names of the artifacts.
    3. Change to add something in the console.log's in other.js
    4. Save, commit and run again in CI/CD process
    5. Compare content hash files names.

    Image

    1. Then uncomment the your plugin by commenting back the lines in webpack.config.js:

    `// plugins: [

    // sentryWebpackPlugin({

    // project: "XXX",

    // org: "XXX",

    // release: process.env.VERSION || "1.0.0",

    // include: "./dist",

    // dryRun: true, // Set to true for testing without uploading

    // }),

    // ],`

    1. Save and commit, let Gitlab CI/CD build again.
    2. Download artifact and see file names.
    3. Now change in other.js again by changing the string in one of the console.log's
    4. Commit and build again
    5. See all file names now changed.

    Image

    My short reference above to "Removing, makes it work again:" was to comment away those lines above.

    Hope this clarifies things.

  6. moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3on Feb 19, 2025
  7. Lms24 commented on Feb 19, 2025

    @Lms24
    Member

    Thanks for providing the reproduction! I can in fact reproduce this locally. in the sense that both the main.* and other.* assets get different hashes when adjusting console logs.

    First off: It seems fairly logical to me that the main.* hash changes because the changed console.log from other.js gets pulled into the main. bundle.

    Your Webpack plugin config is outdated, probably from a time where you used version 1 of the plugin(?). Here's an updated version:

    plugins: [
      sentryWebpackPlugin({
        project: "hbbtv-client",
        org: "sveriges-television",
        release: {
          name: process.env.VERSION || "1.0.0", // <--- `release.name` is the new `release`
        }
        sourcemaps: { // <-- you probably don't need to set this at all, as we auto detect assets since v2
          assets: ["dist"],
        },
        // dryRun: true, // <-- no longer available
      }), 
    ],

    As you can see, the release name property shifted, which meant that the plugin couldn't determine a set release name so it fell back to either an environment variable or the git commit sha to set it. This release value gets injected into every bundle. So this likely introduced randomness that led to changes in all files.

    We also further inject a debug id snippet with a unique ID for each file. I think this should be deterministic as long as no file changes occur (cc @lforst to confirm) but likely there was interplay with the release.

    I recommend updating your config and checking if you still get different hashes in places where you wouldn't expect this.

    Note that I didn't reproduce this on Gitlab yes because frankly, if I can avoid creating yet another account I'll do that 😅

  8. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Feb 19, 2025
  9. josefnorlin-svt commented on Feb 25, 2025

    @josefnorlin-svt

    Thank you! That, along with the correct project and auth key, solved the issue. I find it a bit strange that a misconfiguration in the Sentry setup caused the content hashes to change. Is it supposed to work this way? If so, would it be a bad idea to show a warning about it?

  10. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Feb 25, 2025
  11. josefnorlin-svt commented on Feb 25, 2025

    @josefnorlin-svt

    I've updated the code to better split concerns of main.js (index.js) and other.js (other.js) file to better show this in the project linked here:

    https://github.com/svt/sentry-webpack-repro

  12. Lms24 commented on Feb 26, 2025

    @Lms24
    Member

    Glad it works for you now! I'll close this issue as completed then but I'll raise the question of checking/validating configs better.

    My 2 cents around this are that it's very hard to check against properties being set that we don't expect (as per our current type definition). Maybe we can special-case some known properties like include or a string value for release.
    Worth noting that we already check against misconfiguration of known properties (e.g. invalid/malformed auth tokens).

  13. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Feb 26, 2025
  14. josefnorlin-svt commented on Feb 28, 2025

    @josefnorlin-svt

    @Lms24 No, I don't think this is solved. Since your plugin breaks the content hashes when things are misconfigured. At least a warning would be good for the end user right?

    Imagine how many cashes get busted and the amount of extra internet traffic this generates since files don't get cached anymore.

  15. lforst commented on Mar 3, 2025

    @lforst

    Thanks for the feedback. We'll keep it in mind. Currently we don't plan on changing anything. I hope this doesn't sound dismissive - it's a matter of prioritization

  16. axelson commented on Jul 11, 2025

    @axelson

    I'm running into this same issue as well. We have a vendor chunk that we want to be long-lived, so we want Sentry to use @sentry/webpack-plugin to upload the source maps to sentry. But we don't want the vendor chunk to cache-busted with each deploy (since right now the deploys include the sha which changes each time).

    Or maybe at least this behavior can be mentioned here: https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/webpack/

    Is there a workaround? Could we upload the source maps without using the plugin?

  17. GrinZero commented on Sep 16, 2025

    @GrinZero

    The injection of Sentry causes 100% invalidation of the user's cache every time we update it, which is a very serious issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions