Skip to content
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

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

Open
Juice10 opened this issue Mar 27, 2024 · 1 comment
Open

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

Juice10 opened this issue Mar 27, 2024 · 1 comment

Comments

@Juice10
Copy link

Juice10 commented Mar 27, 2024

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.

new BannerPlugin({
raw: true,
include: /\.(js|ts|jsx|tsx|mjs|cjs)$/,
banner: (arg?: BannerPluginCallbackArg) => {
const debugId = arg?.chunk?.hash ? stringToUUID(arg.chunk.hash) : uuidv4();
return getDebugIdSnippet(debugId);
},

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"));
@lforst
Copy link
Member

lforst commented Mar 27, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants