-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Conflicting asset ids leads to wrong file being required #2180
Comments
So i dug a bit and I guess in production mode it slices off the first 4 characters of an md5 hash of the relative filename (https://github.com/parcel-bundler/parcel/blob/master/packages/core/parcel-bundler/src/Asset.js#L199)... and these two:
Both end up with the same value. |
Did some math for fun: in a project that includes 2000 files (around my size) there is a 0.012% chance that this will happen! |
I'm not sure if it's worth it to think of a fix since I can just change the filename, but maybe we could warn or throw during build if the asset ids exist aready but the names don't match. |
This should fix this: #1803 |
It looks like I do also fall under the 0.012%! :) Renaming my file fix the issue but still not ideal solution. |
This bug is still present in
it generates the same ID = const crypto = require('crypto');
const fs = require('fs');
function md5(string, encoding = 'hex') {
return crypto
.createHash('md5')
.update(string)
.digest(encoding);
}
[
"components/rules/EasySelectorField.tsx",
"components/actions/ActionForm.tsx"
].forEach(file => {
console.log(file, md5(file, "base64").slice(0, 4));
}); It's a little bit frustrating |
@DeMoorJasper you wrote in the PR:
Is this code responsible for generating IDs? https://github.com/parcel-bundler/parcel/blob/master/packages/core/parcel-bundler/src/Asset.js#L204 If so, then I would argue that it's very likely that we can have duplicates of IDs. if (!this.id) {
this.id =
this.options.production || this.options.scopeHoist
? md5(this.relativeName, 'base64').slice(0, 4)
: this.relativeName;
} Just 4 characters long ID/hash is not enough and I don't see any code responsible for checking duplicates |
@lukejagodzinski yes it's possible, it's just unlikely (on small projects) once you have a large project or are a bit unlucky you can def have duplicates. Feel free to look at my PR and open up a new PR with the same/similar code |
@DeMoorJasper it's a huge PR and I just can't find file that makes a change. Could you point me to the commit that checks for duplicates? |
@DeMoorJasper Thanks! I will take a look at it and propose my solution. It looks like this change is not even merged. It was probably overridden by some other PR. Someone just didn't take time to review it |
@lukejagodzinski yes it never got reviewed/merged |
@DeMoorJasper hmmm for me it looks good. Actually I wouldn't change anything there. Is there anyone that could just merge it and release new version? |
@lukejagodzinski impossible as master had a force push that messed up the history. Would have to re-create the PR |
@DeMoorJasper could you recreate this PR? |
Sure, just opened it as #2999 it was just a copy paste and it worked |
Hope it will be reviewed and merged soon :) |
I also experienced this issue. I applied the patch of #2999 and it solved it. Can I do something to help get this merged in the next bug fix release? Thks! |
@tibdex as you can see this issue has |
Should be fixed in v2 |
🐛 bug report
I ran into an issue only seen when building in production that when lodash's clone method was called it would lead to the following error:
I tracked it down to this line here: https://github.com/lodash/lodash/blob/master/.internal/baseClone.js#L200 and added some extra logging around it. What I found was that the "Stack" variable, which should be a reference to an imported lodash function, was actually the string '/authorize_change_trust.5c3cd8f3.png', which is the generated filename for one of the images that import in another file.
I tracked it down further and found that the requires map to the same ID:
So somehow, only in the production build, these things are being mapped to the same id. Everything is fine in dev/watch mode.
🎛 Configuration (.babelrc, package.json, cli command)
.babelrc
💻 Code Sample
This is happening here: https://github.com/stellarguard/stellarguard but it's happening in a dependency of this project, not directly in the call site.
I will try to come up with a smaller reproduction step but I'm not sure I'll be able to since the bug probably relies on a lot of little things falling into place to cause a clash.
🌍 Your Environment
The text was updated successfully, but these errors were encountered: