-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
webpack does not generate always unique chunk hashes #1155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
👍 |
Yes, it would be nice if you could send me two different files which identical hash so I could reproduce it. |
Should be fixed. |
Good news. Could you please share with us what was wrong? |
The hashes of referenced chunks were not included in the chunkhash of the entry chunks. A entry chunk include a list of urls of all additional chunks that can be loaded. Depending on the configuration there is a flag for each chunk whether it need to use to global hash or the chunk hash for caching. webpack now throws an error when using The first change ensures that there is an error when The second change ensures that |
@sokra That's great, but still I cannot find a new release or something like that to install/update. |
@sokra Ping. I am not able to find the fix you're talking about. |
I have the same problem. Files are identical (looking through v1.12.2 |
I'm having the same problem as @dmitry both hash and chunkhash are different on different machines for the same git commit. |
@viz looks like the absolute path is the root of the issue. |
@dmitry - have you been able to fix it or found a work-around? My problem is that I need builds on CircleCI and Heroku to have the same hash... |
hmm, I tried that but I still get different hashes on Circle versus Heroku. Perhaps I'm doing something wrong - I am new to webpack, so I'm not completely clear on the whole config. Like you, I started with react-redux-universal-hot-example but adding webpack-md5-hash as per the readme doesn't fix it for me... |
I am still getting the issue with latest version. I am afraid this one wasn't fixed. |
I found the issue is appears when imported library imports at least one file in itself. For example, I've tried remove all the react imports (requires) - hash was generated identically, then I've tried to import one library in a react library - it started to generate hash differently. It depends on absolute path, because I was able to reproduce that issue on the same machine but with different root paths. If you want to see all the issues with related problem, check out this issue: #1479 |
yes, I found that one as well - unfortunately seems it is still an outstanding bug. If I had the skill to develop a patch I would, but getting into the guts of webpack is a bit beyond me at the moment. I'll have to look for another solution.. |
@dmitry Are you using a particular webpack version? I am getting an error using latest version (1.12.6) and webpack-dev-server as well (1.12.1) |
@XVincentX here we are using webpack 1.12.2, webpack-dev-server version doesn't matter, because it only starts in development, but we have an issue with the production bundle too. |
1.12.2 here as well Sent from my iPad
|
@dmitry |
For me adding the |
@bradrobertson no common chunks plugin used in our webpack config. |
I am using them. Perhaps it's the reason for the error I'm getting. |
Looks like this isn't fixed as of |
@dtothefp I tagged the issue under |
@bebraw thanks...this is a very bad bug because if you are using subresource integrity and filenames overlap sometimes the CDN will serve previously cached content that does not match the subresource integrity hash for the current bundle, and therefore the JS/CSS generated through Webpack will not load |
Yep, that sounds pretty bad. Do you have a way/repo to reproduce it reliably? That would be a big help. |
@jhnns essentially it took months of build up in S3 for this to start happening. I'm using Essentially here is the flow that results in failure that took us a while to figure out what was going on:
I wish I could reproduce when / how this happens but it seems to start showing up lately across many of our applications through many Travis CI builds that upload static assets to S3. I resorted to using the md5 webpack plugin and seems to be working for now. |
As far as I'm understanding it, we have two issues here:
Please note that webpack hashes the final result (chunks and assets), which means that loaders and plugins have been executed before. Thus it is possible that you don't get the same hashes for the same file content, because you might have installed different versions of loaders and plugins (at least when using npm). Same goes the other way round. For instance, if you're using tree-shaking, you might get the same hashes for different file contents if unused code is removed. It would be very helpful if you could reproduce the error without any plugin. @dtothefp maybe it's an error with the sri-stats-webpack-plugin? Try to remove as much as the possible so that we can locate the error. |
I'm using webpack 2, and it's so bad I always need to go fiddle with the urls. I've thrown in all the things: |
@dtothefp Nope. It's a huge and complicated issue and I don't think there's a simple fix in sight. Reading back, a minimal case to showcase the problem would likely help. |
@bebraw I just quickly put together this repo https://github.com/dtothefp/webpack-broken-sha. Made a branch where I changed JS slightly and got a different sha so What we saw in the past is that this happened overtime, some deploys with differing content had the same hash and some had different. The only way we knew is when subresource integrity broke because it got cached content (i.e. a deploy with changed content had the same hash as a previous deploy and the CDN served the previous deploys content). If anyone wants to play around with the repo above to try and reproduce feel free. It's just a basic setup with React and CSS modules. |
Anyone using https://github.com/scinos/webpack-plugin-hash-output plugin to work around this problem? It generate the hash from the final content files. |
@le12484 I am using https://github.com/erm0l0v/webpack-md5-hash and it has been working fine for me these past few months. |
The same hash in filename for different entry files with different contents. Why? Is it normal behavior? child.js
fileA.js
fileB.js
webpack config.js
|
Switching from
|
As @le12484 recommended, I wrote https://www.npmjs.com/package/webpack-plugin-hash-output to precisely fix this problem. It guarantees that you'll get a It even has the option to fail the compilation if, for whatever reason, that postcondition is not met (see option |
This issue had no activity for at least half a year. It's subject to automatic issue closing if there is no activity in the next 15 days. |
Issue was closed because of inactivity. If you think this is still a valid issue, please file a new issue with additional information. |
Hello,
we have noted that sometimes webpack generates the same hash for a chunk, even if the file content has been changed.
Due to this, changes sometimes are not propagated, we experience an error similar to #959 and we're forced to clear the cache/CDN to make the things work.
We are using the following plugins in the given order:
Let me know if you need further details,
V.
The text was updated successfully, but these errors were encountered: