Sentry source maps: upload them and fix minified traces
Sentry turns minified JavaScript frames back into your original files by matching each bundle to its source map through a Debug ID. Run npx @sentry/wizard@latest -i sourcemaps, or add Sentry's bundler plugin, or run sentry-cli sourcemaps inject and then sentry-cli sourcemaps upload on your build output, always before you deploy. If traces are still minified, the deployed files almost always lack the Debug ID snippet, or the maps were uploaded after the error happened.
Steps
- Generate maps in productionTurn on hidden source maps in your bundler for the production build.
- Inject Debug IDsUse Sentry's bundler plugin or run sentry-cli sourcemaps inject on the build output.
- Upload before deployingRun sentry-cli sourcemaps upload (or let the plugin upload) with SENTRY_AUTH_TOKEN, then deploy the injected files.
- Verify with a new errorTrigger an error on the new deploy and confirm the frames show your file names and source context.
How matching works: Debug IDs
Since SDK 7.47.0, Sentry links an event to its source map by Debug ID rather than by release name and file URL. Injection adds a unique ID to each minified file and to its map. This is what sentry-cli sourcemaps inject dist does to a file (output from sentry-cli 3.8.2, shortened):
!function(){try{var e="undefined"!=typeof window?window:...;
e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9c30da67-2a0a-5916-9be7-42229a44d74a"}catch(e){}}();
function a(){throw new Error("x")}a();
//# sourceMappingURL=app.min.js.map
//# debugId=9c30da67-2a0a-5916-9be7-42229a44d74aThe map gets a matching "debugId" field and its mappings are shifted for the added lines. At runtime the snippet registers the ID, the SDK puts it in the event's debug_meta, and Sentry finds the map with the same ID. Two consequences: the files you deploy must be the injected ones, and you no longer need to get release or URL prefixes exactly right for matching.
Upload source maps: wizard, bundler plugin or sentry-cli
The quickest route is npx @sentry/wizard@latest -i sourcemaps, which detects your tool and writes the config. Maps are generated and uploaded only in production builds.
| Tool | Setup (as of November 2026) |
|---|---|
| Vite | sentryVitePlugin from @sentry/bundler-plugins/vite, build.sourcemap: "hidden", plugin last in plugins |
| webpack | sentryWebpackPlugin from @sentry/bundler-plugins/webpack, devtool: "hidden-source-map" |
| Rollup, esbuild | Sentry's Rollup and esbuild plugins; esbuild doesn't get deterministic Debug IDs |
| tsc, anything else | sentry-cli |
| React Native, Flutter web | Their own SDK tooling: React Native, Flutter |
Current docs install all bundler plugins from one package, npm install @sentry/bundler-plugins --save-dev. A Vite config:
import { defineConfig } from 'vite';
import { sentryVitePlugin } from '@sentry/bundler-plugins/vite';
export default defineConfig({
build: { sourcemap: 'hidden' },
plugins: [
react(),
sentryVitePlugin({
org: 'acme',
project: 'web',
authToken: process.env.SENTRY_AUTH_TOKEN,
sourcemaps: { filesToDeleteAfterUpload: ['./dist/**/*.map'] },
}),
],
});With sentry-cli (2.17.0 or later), the order is build, inject, upload, deploy:
export SENTRY_ORG=acme SENTRY_PROJECT=web
npm run build
npx sentry-cli sourcemaps inject ./dist
npx sentry-cli sourcemaps upload ./dist
# now deploy ./dist--release and --dist are optional with Debug IDs but still associate the files with a release. "hidden" maps omit the sourceMappingURL comment, so browsers don't fetch them, and filesToDeleteAfterUpload keeps them off your server.
Diagnose a minified trace, step by step
- Is the deployed file injected? Fetch the bundle from production (not your local
dist) and search for_sentryDebugIdsand//# debugId=. Missing means you injected after deploying, deployed a different build, or the plugin isn't running. Sentry reports this case asSentry not part of build pipeline. - Does the event carry the ID? In the event JSON,
debug_metamust list acode_fileexactly equal to each frame'sabs_path. Nodebug_metameans an SDK older than 7.47.0. - Is the map in Sentry? Check Settings → Projects → web → Source Maps: both the minified file and its map must be there with the same Debug ID.
- Was it uploaded before the error? Sentry doesn't re-process events received before the upload.
- Is the map itself right? Resolve one position locally from the frame's line and column:
npx sentry-cli sourcemaps resolve dist/assets/index.js.map --line 1 --column 48213. If that also points to the wrong place, the bundler's map is wrong and Sentry is innocent. Check that the map includessourcesContent.
Common causes, most frequent first
| Cause | Fix |
|---|---|
| Deploy happened before or without inject | Move inject and upload before the deploy step in CI |
No SENTRY_AUTH_TOKEN in CI, upload silently skipped | Set the token; pass --strict to sentry-cli to fail when a map can't be uploaded |
| Dev or watch build shipped | Upload from the production build only |
| Another plugin changes files after Sentry's | Put the Sentry plugin last |
| Maps compressed before upload | Upload plain text, or --decompress (sentry-cli 2.4.0+); compress afterwards |
source-map-support in a browser bundle | Remove it; it breaks stack parsing |
| Map larger than 190 MiB | Split the bundle; Sentry ignores larger maps |
The mistake people make next: "fixing" it by making maps public with a sourceMappingURL and turning on Enable JavaScript source fetching. That works only for code anyone can download, exposes your source, and still breaks on the next build that isn't reachable. Upload instead. Once traces are readable, read the stack trace from the top in-app frame; for a typical first readable error, see Cannot read properties of undefined.
Questions
Do Sentry source maps still need a release?
Not for matching. With Debug IDs (SDK 7.47.0+), Sentry links the event to the map by ID; --release and --dist only associate the files with a release.
Why are old errors still minified after I uploaded maps?
Sentry applies source maps when it processes an event and doesn't re-process events received earlier. New events from the injected build will be readable.
Should I deploy .map files to my server?
No need. Sentry reads uploaded maps, so build hidden maps and delete them after upload with filesToDeleteAfterUpload.
Sources
- Source Mapsdocs.sentry.io
- Sentry CLIdocs.sentry.io
- Troubleshooting Source Mapsdocs.sentry.io
- Vitedocs.sentry.io