-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Injected debug id causing hash differences in cross-architecture builds #15745
Injected debug id causing hash differences in cross-architecture builds #15745
Comments
Hi @Redmega, thanks for filing this. Afaik, debug ids are generated based on code, hashes are stripped from the file endings. Are you observing consistent hashes without Sentry? cc @lforst |
What are you using to inject debug IDs? The CLI? If so, it should inject a deterministic uuid based on file-content. |
Sorry, not sure why I had We also use nxComposePlugins(withNx, withBundleAnalyzer, (config) => withSentryConfig(config, sentryConfig))(nextConfig);
Yes, hashes are consistent between architectures when not using the sentry plugin (caveat: I replace ARM (No Sentry)
AMD (No Sentry)
I also went into the differently hashed files (in this case it was only ARM (Sentry)
AMD (Sentry)
Looking at the logs, I suspect that sentry is injecting the code before nextjs has calculated the hashes and output the files, so when nextjs calculates the contenthash they are different. As to why the uuid is different between the two architectures for the same file contents, I'm not sure. I need to dig into the intermediary steps more. |
Actually, in the webpack plugin which is what the nextjs plugin uses under the hood I believe? const debugId = arg?.chunk?.hash ? stringToUUID(arg.chunk.hash) : uuidv4(); It's my understanding that |
As a workaround I wrote a plugin to patch the BannerPlugin added by sentry to look at contentHash instead of hash. Now my build artifacts match across architectures. class SentryDebugIdPatchPlugin {
wrapBanner(bannerPlugin) {
bannerPlugin.banner = (arg) => {
if (arg?.chunk?.contentHash?.javascript) {
return bannerPlugin.options.banner({ chunk: { hash: arg.chunk.contentHash.javascript } });
}
return bannerPlugin.options.banner(arg);
};
}
apply(compiler) {
const bannerPlugin = compiler.options.plugins.find(
(p) => p.constructor.name === "BannerPlugin" && p.banner?.toString().includes("getDebugIdSnippet"),
);
this.wrapBanner(bannerPlugin);
}
} I think an option to use the content hash instead of the chunk hash would be ideal for usecases like this. |
Ah, great find. Making this configurable for webpack sounds reasonable to me, wdyt @lforst? |
@andreiborza I don't think an option is necessary. I don't think hash is different for every build, but we can just default to contentHash and fall back to hash. |
You're right actually, I just tested without the sentry plugin at all (and reverting my |
Good callout @lforst thanks. I looked deeper at the build logs and tried different configurations. With sentry plugin added, it seems like the chunk hash can differ between the builds when they are processed in a different order. No idea why this doesn't occur when the sentry plugin is removed. AMD
ARM
Note the content hashes are identical, and even the Nevertheless, using contenthash instead of chunkhash does seem to resolve all my issues. So... 🤷 |
Thanks for the followup! We'll just default to contentHash and use chunk.hash if that's not available. |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nextjs
SDK Version
^9.5.0
Framework Version
next ^14.2.24
Link to Sentry event
No response
Reproduction Example/SDK Setup
No response
Steps to Reproduce
Expected Result
Content hashes should be consistent across architectures. I think we can accomplish this by specifying which hash the debugId uses, I suspect it's using the id/chunkhash and not the contenthash?
Actual Result
Content hashes are different across architectures. Similar to the issue described in #13971
The text was updated successfully, but these errors were encountered: