sentry-webpack-plugin + electron(-forge) breaks universal builds
Environment
MacOS 14.1.1 (23B81) (intel)
"@sentry/electron": "^4.17.0",
"@sentry/webpack-plugin": "^2.14.3",
"@electron-forge/cli": "7.2.0",
"@electron-forge/maker-deb": "7.2.0",
"@electron-forge/maker-dmg": "7.2.0",
"@electron-forge/maker-rpm": "7.2.0",
"@electron-forge/maker-squirrel": "7.2.0",
"@electron-forge/maker-zip": "7.2.0",
"@electron-forge/plugin-webpack": "7.2.0",
"@electron-forge/publisher-github": "7.2.0",
"@electron-forge/shared-types": "7.2.0",
Steps to Reproduce
Create electron project, add @sentry/electron, electron-forge (with webpack template), and add @sentry/webpack-plugin to the list of webpack plugins.
Run yarn electron-forge publish --arch=universal (on a Mac, or GitHub Actions macOS runner)
Expected Result
Should create a universal package.
Actual Result
Outputs an error:
Error: Expected all non-binary files to have identical SHAs when creating a universal build but "Contents/Resources/app/.webpack/renderer/****/index.js" did not
at makeUniversalApp (/Users/runner/work/desktop/desktop/node_modules/@electron/universal/src/index.ts:131:15)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async packageUniversalMac (/Users/runner/work/desktop/desktop/node_modules/@electron/packager/src/universal.ts:59:3)
at async Promise.all (index 0)
at async packager (/Users/runner/work/desktop/desktop/node_modules/@electron/packager/src/packager.ts:246:20)
error Command failed with exit code 1.
Reason being, webpack is run twice, once for arm64 and once for x86. All the files inside include a webpack banner that uses arg.chunk.hash which is different for each webpack run.
https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/6fd1363a2c36ab087308db627eab243a7a473362/packages/webpack-plugin/src/index.ts#L106-L112
That outputs to a banner looking like this at the top of each non-binary file, where the _sentryDebugIds[t] and _sentryDebugIdIdentifier is different for each run (arm64 & x86):
((e._sentryDebugIds = e._sentryDebugIds || {}),
(e._sentryDebugIds[t] = "dfa51fb7-3d72-4c3b-a810-78409f28b141"),
(e._sentryDebugIdIdentifier =
"sentry-dbid-dfa51fb7-3d72-4c3b-a810-78409f28b141"));
Hi, thanks for writing in and doing the research! I don't think we will fix this soon. I recommend using Sentry CLI instead to upload source maps for the time being. We should probably add an option to disable debug ID injection and also investigate whether there is a more stable way to create a hash for the debug IDs.
I believe this is a similar issue https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/591
If you set sourcemaps.disable on the latest version of the plugin, it will not inject debug ID snippets but you will have to resort to the release.uploadLegacySourcemaps option for sourcemaps.
Will close this in favor of cleanup. Feel free to open it again.