Repository navigation
@sentry/vite-plugin silently breaks event capture when combined with tauri-plugin-sentry #916
Description
I'm having problems using @sentry/vite-plugin with Tauri as it breaks the error logging. I've narrowed it to be the source maps generation. If I disable it the errors shows up in Sentry, if I enable it again the errors does not... I have a minimal reproducible example here: https://github.com/ottosson/sentry-vite-plugin-repro.
I've used Claude to find the problem and generate an issue (slop warning):
Summary
In a Tauri 2 app that uses tauri-plugin-sentry (which injects @sentry/browser into the webview and routes envelopes through a Tauri IPC transport to the Rust SDK), activating @sentry/vite-plugin at build time silently prevents most runtime errors from reaching Sentry. Manual Sentry.captureException(new Error(...)) still works, but errors thrown inside React event handlers, setTimeout callbacks, or any code path wrapped by browserApiErrorsIntegration are dropped. The SDK returns a looking-fine event ID; no envelope is ever produced.
The failure is narrowed to the plugin's per-chunk debug-ID injection:
- Plugin skipped (
SENTRY_AUTH_TOKENunset at build) → every capture arrives. - Plugin active with
sourcemaps.disable: true→ every capture arrives. - Plugin active with default config → only manual captures arrive.
Minimal reproducer
https://github.com/ottosson/sentry-vite-plugin-repro (please fork/upload from the attached repro folder)
Three-button Tauri 2 app; each button exercises a different capture path. README walks through the three build variants.
Steps:
npm install- Replace DSN in
src-tauri/src/lib.rsand org/project invite.config.ts. - Build with plugin active:
$env:SENTRY_AUTH_TOKEN = "sntrys_..." npm run tauri build
- Install, click all three buttons.
- Observe in Sentry: only button 3 (manual capture) lands. Buttons 1 and 2 show
Uncaught Error: ...in devtools console but produce no Sentry events. - Rebuild with
SENTRY_AUTH_TOKENunset, or withsourcemaps: { disable: true }in the plugin config → all three buttons now produce events.
Environment
@sentry/vite-plugin5.2.0 (also reproduces on 5.1.1)@sentry/browser10.46.0 (transitively viatauri-plugin-sentry)tauri-plugin-sentrylatest onmain(timfish/sentry-tauri)- Tauri 2.10.x, React 19.2.x,
react-dom19.2.x - Vite 8.0.x,
@vitejs/plugin-react6.0.x - Windows 11, WebView2 Evergreen
- Node 20+
Diagnostic observations
Hooking window.__TAURI_INTERNALS__.invoke to observe plugin:sentry|envelope calls:
- Path A (plugin active):
Sentry.captureException(err)invocations for React-onClick errors return an event ID but no envelope is invoked at the IPC level. - Path B (plugin absent): same code path produces an envelope.
Other observations that partially isolate the issue:
- The thrown error has
__sentry_captured__ === trueafter Sentry'sbrowserApiErrorsIntegrationwrapper runs. Explicitly stripping this marker does not restore delivery. dedupeIntegrationremoval viaintegrations: (d) => d.filter((i) => i.name !== "Dedupe")does not restore delivery on its own.setTimeout(() => Sentry.captureException(err), 0)deferral does not restore delivery.- Manual capture with a completely fresh
new Error()(unique message + fresh stack) does land — which is why we suspect dedupe or marker-based gating at first, but those turn out not to be the individual cause. - Only avoiding the plugin's chunk-level debug-ID injection (either via
sourcemaps.disable: trueon the plugin, or by skipping the plugin entirely) restores delivery.
The injected snippet the plugin prepends to each chunk:
try {
globalThis._sentryDebugIds = globalThis._sentryDebugIds || {};
globalThis._sentryDebugIds[new Error().stack] = "<uuid>";
} catch {}Something about this snippet — its timing, or the Error creation/stack capture, or the globalThis mutation — interacts with @sentry/browser v10's browserApiErrorsIntegration + dedupeIntegration in a way that causes the wrapper's own internal capture (and any subsequent application capture of the same error) to be silently dropped. I have not been able to pin it to a single integration.
What we need
Either:
- Confirmation that this combination (plugin +
tauri-plugin-sentry's custom transport) is not a supported configuration, along with guidance on what to configure differently — or - A fix in either the plugin's injection strategy or
@sentry/browser's capture gating so that events produced during or after the wrapper's catch aren't silently discarded.
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsNo status
Activity
linear-code commentedon Apr 20, 2026
BUNDLER-117
logaretm commentedon Apr 20, 2026
Thanks for reporting, our team is already looking into this and will report back.
timfish commentedon Apr 22, 2026
@ottosson is your repro still private? I can't access it!
ottosson commentedon Apr 22, 2026
@timfish sorry about that! It's public now
timfish commentedon Apr 24, 2026
Struggling a bit to reproduce this. I appear to get issues for the first two buttons but I've only tried in development mode:
ottosson commentedon Apr 24, 2026
Are you sure your VIte config is building with sentryVitePlugin set?
I think I only got this issue when building for production. Not sure it's required, but worth a shot
timfish commentedon Apr 24, 2026
Yes, I removed the conditional and just add the plugin like this. With an invalid auth/org/project the plugin injects as usual and simply reports an error for uploading to Sentry.
I will check production!
ottosson commentedon Jun 2, 2026
I've used Claude (Opus 4.8) to really dig into this again. It claims to have found the root cause, which is not the Vite plugin apparently!
I don't mean to bloat your inbox with loads of AI output, but I have verified the solution and it seems to work. I don't however know if the solution is the best approach. I leave that up to you :)
Here's a fork with the fix: https://github.com/ottosson/sentry-tauri
Claude:
Root-caused — and it isn't
@sentry/vite-plugin. Posting the full chain in case anyone else lands here; I think this issue can be closed on this repo and tracked downstream.TL;DR
The plugin is behaving correctly. With debug-ID injection on,
@sentry/browserattaches a source-map debug image to every event:In a Tauri app that uses
tauri-plugin-sentry, frontend events are sent over IPC to the Rust process, which deserializes them withsentry::Envelope::from_slice. That eagerly parses the event item —envelope.rs#L645:…into
sentry_types::protocol::Event, andsentry-rust'sDebugImageenum (v7.rs#L903-L915) is a closed#[serde(tag = "type")]with onlyapple/symbolic/proguard/wasm— nosourcemapvariant and no catch-all:So deserialization fails with
EnvelopeError::InvalidItemPayload(envelope.rs#L39),from_slicereturnsErr, andtauri-plugin-sentrysilently skips it — itsif let Ok(envelope)has no error arm (commands.rs#L20-L22). Every frontend event is dropped. Settingsourcemaps: { disable: true }or removing the plugin dropsdebug_meta→ events flow again, which is what made it look like a bundler-plugin bug.Versions: my app compiles
sentry-types0.42.0 (viasentry 0.42), but the gap is identical at0.46.2(latest) and0.42.0, so a version bump doesn't fix it.Reproduction / proof
Tauri 2 app +
tauri-plugin-sentry+ a frontend built with this plugin andSENTRY_AUTH_TOKENset. Throw from a React handler. Verified end-to-end against a live project:Envelope::from_slicereturnsinvalid item payload;src/*.tsxframes.Where the actual fixes belong
1.
tauri-plugin-sentry—src/commands.rs,fn envelope.Today (
L20-L22):Don't drop on parse failure — forward the raw bytes (keeps
debug_meta, so server-side debug-ID symbolication still works).Envelope::from_bytes_rawalready exists for this:2.
sentry-rust—sentry-types/src/protocol/v7.rs,enum DebugImage.Give it a
SourceMapvariant, or anOther(Map<String, Value>)catch-all so unknown/forward-compatible debug-image types round-trip instead of failing the whole event. There's direct precedent in the same file: theContextenum already ends with one —v7.rs#L1106-L1107:timfish commentedon Jun 3, 2026
Thanks, this does sound like it's the cause and the fixes sound convincing!
I'll take another look.
timfish commentedon Aug 17, 2026
This has been fixed in the latest release