Skip to content

fix(desktop): bundle Sentry and add sourcemap uploads#875

Merged
saddlepaddle merged 2 commits intomainfrom
fix/sentry-electron-bundling
Jan 21, 2026
Merged

fix(desktop): bundle Sentry and add sourcemap uploads#875
saddlepaddle merged 2 commits intomainfrom
fix/sentry-electron-bundling

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented Jan 21, 2026

Summary

  • Remove @sentry/electron from Vite externals so it gets bundled properly (fixes "Failed to resolve module specifier" error in renderer and missing module in production main process)
  • Add @sentry/vite-plugin for automatic sourcemap uploads to Sentry
  • Enable sourcemaps for both main and renderer builds
  • Add SENTRY_AUTH_TOKEN to CI workflow for sourcemap uploads

Root Cause

When @sentry/electron was externalized:

  1. Renderer: Browsers can't resolve bare module specifiers like @sentry/electron/renderer - they need bundled code or URLs
  2. Main process: The module wasn't included in electron-builder's files, so it wasn't available in the packaged app

Test plan

  • Trigger desktop build workflow on this branch
  • Download and run the built app
  • Verify Sentry initializes without errors in both main and renderer
  • Check Sentry dashboard for uploaded sourcemaps

Summary by CodeRabbit

  • Chores
    • Improved error reporting and monitoring for the desktop app to help identify and resolve crashes faster.
    • Enabled source map generation for desktop builds to improve stack traces and diagnostics in production.
    • Increased build memory and added required build tooling to support reliable desktop build and CI workflows.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 21, 2026

📝 Walkthrough

Walkthrough

Adds Sentry Vite plugin and sourcemap generation to the desktop build, increases Node memory for compilation, and exposes SENTRY_AUTH_TOKEN in the CI compile step for conditional sourcemap upload during builds.

Changes

Cohort / File(s) Summary
Build configuration & CI
apps/desktop/electron.vite.config.ts, .github/workflows/build-desktop.yml
Integrates @sentry/vite-plugin into main and renderer builds with conditional activation based on SENTRY_AUTH_TOKEN; enables sourcemaps; adds SENTRY_AUTH_TOKEN to the CI compile step environment.
Package & deps
apps/desktop/package.json
Increases --max-old-space-size from 4096 to 8192 in the compile:app script; adds @sentry/vite-plugin ^4.7.0 to devDependencies.

Sequence Diagram(s)

sequenceDiagram
  participant CI as CI runner
  participant Build as Vite/Electron build
  participant Sentry as Sentry API

  CI->>Build: set env SENTRY_AUTH_TOKEN (from secrets) and start compile
  Build->>Build: initialize `@sentry/vite-plugin` if token present
  Build->>Build: generate sourcemaps for main & renderer bundles
  Build->>Sentry: upload sourcemaps via Sentry plugin (when initialized)
  Sentry-->>Build: upload response/status
  Build-->>CI: finish compile (artifacts + status)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 In burrows of build, I hop and peep,
Sourcemaps tucked where secrets sleep,
Tokens fetched from CI's bright glen,
I guard the stacktraces now and then,
✨🐇

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main changes: fixing Sentry bundling and adding sourcemap uploads to the desktop build.
Description check ✅ Passed The PR description is comprehensive and well-structured, clearly explaining the root cause, changes made, and test plan, though it doesn't follow the exact template structure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 21, 2026

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch
  • ✅ Electric Fly.io app

Thank you for your contribution! 🎉

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@apps/desktop/package.json`:
- Line 134: The package dependency "@sentry/vite-plugin" in package.json is
pinned to "^4.7.0" which doesn't support Vite 7; update the dependency entry for
"@sentry/vite-plugin" to a version that supports Vite 7 (e.g., "^4.8.0" or
later), then reinstall/update the lockfile so the new version is applied and run
your normal build to verify no regressions; check the package.json entry and the
lockfile after updating to ensure the new version was resolved.
🧹 Nitpick comments (1)
apps/desktop/electron.vite.config.ts (1)

74-75: Consider stripping .map files from packaged artifacts.
Enabling production sourcemaps can ship source with the desktop app. If that’s not desired, consider excluding .map files during packaging or deleting them post-upload.

Also applies to: 190-191

Comment thread apps/desktop/package.json
"zustand": "^5.0.8"
},
"devDependencies": {
"@sentry/vite-plugin": "^4.7.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# Find and read electron.vite.config.ts to see the Sentry plugin configuration
fd -t f "electron\.vite\.config\.ts" apps/desktop/

Repository: superset-sh/superset

Length of output: 184


🏁 Script executed:

# Read the package.json to check Vite and electron-vite versions
cat -n apps/desktop/package.json | head -50

Repository: superset-sh/superset

Length of output: 184


🏁 Script executed:

# Also check if there are any other Sentry-related configs or version constraints
rg "sentry|vite-plugin" apps/desktop/package.json -i

Repository: superset-sh/superset

Length of output: 184


🌐 Web query:

@sentry/vite-plugin v4.7.0 Vite 7 compatibility requirements

💡 Result:

Do you want me to fetch the exact peerDependencies/package.json for @sentry/vite-plugin v4.7.0 (to confirm which Vite versions it supports)?


🌐 Web query:

@sentry/vite-plugin release option configuration electron-vite

💡 Result:

Summary — how to configure the plugin's release options when using @sentry/vite-plugin with electron-vite

Key facts

  • @sentry/vite-plugin exposes a release option object with most-used fields: name (or SENTRY_RELEASE env var), inject, create, finalize, dist, vcsRemote, setCommits, deploy, cleanArtifacts, etc. Use release.name to force a specific release identifier. [1][2]
  • For Electron (electron-vite) you normally build separate targets (main, preload, renderer). Use the Sentry plugin in each Vite config (renderer and, if you upload main sourcemaps, main/preload) and ensure all builds use the same release name so Sentry groups errors correctly. [3][1]

Minimal example (electron.vite.config.ts)

  • ensure sourcemaps are enabled for the builds that upload maps
  • set a shared release.name (or export SENTRY_RELEASE in CI)
  • put sentryVitePlugin in the appropriate build plugin array

Example snippet:

import { defineConfig } from 'electron-vite'
import { sentryVitePlugin } from '@sentry/vite-plugin'

export default defineConfig({
main: {
build: { sourcemap: true },
plugins: [
sentryVitePlugin({
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
sourcemaps: { include: './out/main' }, // adjust paths as needed
release: {
name: process.env.SENTRY_RELEASE || 'my-app@' + process.env.npm_package_version,
inject: true, // inject release into bundles (recommended)
create: true, // create release on Sentry during build
finalize: true,
dist: process.env.BUILD_NUMBER,
setCommits: { auto: true },
},
}),
],
},
renderer: {
build: { sourcemap: true },
plugins: [
sentryVitePlugin({
/* same org/project/authToken */
release: { name: process.env.SENTRY_RELEASE || 'my-app@' + process.env.npm_package_version, inject: true },
}),
],
},
})

Practical tips

  • Prefer setting SENTRY_RELEASE in CI (same value for main + renderer bundles). The plugin will fall back to auto-detect (git SHA) if name is not provided. [1][2]
  • Ensure sourcemap generation is enabled for the builds you want to upload. [2]
  • If you upload native electron artifacts (e.g., main process), consider uploading those maps/artifacts from the main/build output and set include paths accordingly. [1][3]

Sources

  • @sentry/vite-plugin options (release.* docs). [1]
  • Sentry docs: Vite sourcemaps / release guidance. [2]
  • electron-vite config / multi-target build guidance (where to add the plugin for main/preload/renderer). [3]

🌐 Web query:

@sentry/vite-plugin 4.7.0 peerDependencies Vite version support

💡 Result:

Short answer: @sentry/vite-plugin v4.7.0 supports Vite v4 and v5. See Sentry's Vite docs and the bundler-plugins repo/issues showing usage and compatibility with Vite 4/5. [1][2]

Sources:

  • Sentry docs — Vite sourcemaps / Sentry Vite plugin. [1]
  • getsentry/sentry-javascript-bundler-plugins (package / issues referencing Vite 4 and Vite 5). [2]

🌐 Web query:

@sentry/vite-plugin electron-vite 4.0 compatibility

💡 Result:

Short answer: generally yes — @sentry/vite-plugin can be used with electron-vite, but you must match versions and watch a few caveats.

Details and recommendations:

  • @sentry/vite-plugin targets Vite builds and the official docs show using it in Vite projects for sourcemap/release upload — use the latest @sentry/vite-plugin and enable sourcemaps in your Vite build. [1][2]
  • electron-vite is a Vite-based tool (requires recent Vite — electron-vite docs show Vite 5+ for current releases), so compatibility depends on the Vite version electron-vite uses in your project. Ensure your @sentry/vite-plugin supports that Vite major version. [3]
  • There are community-reported build issues when newer @sentry/vite-plugin versions interact with some Vite setups/plugins (errors uploading/failing builds). Test your full electron-vite build (main/preload/renderer) and adjust sentry plugin config (assets/sourcemap paths, placement after other plugins) if you hit problems. See related issues for troubleshooting. [4]

If you want, tell me your electron-vite version, Vite version, and the @sentry/vite-plugin version you plan to use and I’ll give precise compatibility guidance and a minimal working config.


@sentry/vite-plugin v4.7.0 does not support Vite 7.x — it only supports Vite 4 and 5. If this project uses Vite 7, upgrade to a newer version of @sentry/vite-plugin (v4.8.0+) that supports Vite 7. The release option is fully supported with your configuration.

🤖 Prompt for AI Agents
In `@apps/desktop/package.json` at line 134, The package dependency
"@sentry/vite-plugin" in package.json is pinned to "^4.7.0" which doesn't
support Vite 7; update the dependency entry for "@sentry/vite-plugin" to a
version that supports Vite 7 (e.g., "^4.8.0" or later), then reinstall/update
the lockfile so the new version is applied and run your normal build to verify
no regressions; check the package.json entry and the lockfile after updating to
ensure the new version was resolved.

- Remove @sentry/electron from externals so it gets bundled properly
  (fixes "Failed to resolve module specifier" error in renderer and
  missing module in production main process)
- Add @sentry/vite-plugin for automatic sourcemap uploads to Sentry
- Enable sourcemaps for both main and renderer builds
- Add SENTRY_AUTH_TOKEN to CI workflow for sourcemap uploads
@saddlepaddle saddlepaddle force-pushed the fix/sentry-electron-bundling branch from 522e0e8 to 0dfa30e Compare January 21, 2026 19:58
@saddlepaddle saddlepaddle merged commit aac4cb3 into main Jan 21, 2026
13 checks passed
@Kitenite Kitenite deleted the fix/sentry-electron-bundling branch January 22, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant