sentry-javascript-bundler-plugins icon indicating copy to clipboard operation
sentry-javascript-bundler-plugins copied to clipboard

sentry-webpack-plugin + electron(-forge) breaks universal builds

Open Juice10 opened this issue 1 year ago • 3 comments

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"));

Juice10 avatar Mar 27 '24 14:03 Juice10

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.

lforst avatar Mar 27 '24 15:03 lforst

I believe this is a similar issue https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/591

lilouartz avatar Aug 23 '24 22:08 lilouartz

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.

lforst avatar Aug 26 '24 09:08 lforst

Will close this in favor of cleanup. Feel free to open it again.

s1gr1d avatar Dec 10 '24 08:12 s1gr1d