Skip to main content

How does Sentry use source maps?

Issue

I want to understand how Sentry turns minified JavaScript stack traces into readable, unminified frames, and which source map fields matter when stack traces or source context look wrong.

Applies To

  • All SaaS Customers and Self-Hosted Users

  • Source Maps

Resolution

Sentry uses your minified JavaScript file together with its source map to map each production stack frame back to your original source. For each frame, Sentry looks up the generated line and column in the source map, then resolves the original file path, position, and (when available) identifier name and source code for the UI.

A source map is a JSON file. These keys are the ones that drive unminified stack traces and source context in Sentry:

  • mappings tells Sentry how generated line and column numbers map to original locations

  • sources tells Sentry the original file paths

  • names provides original identifier names used by the mappings (the same name you see when verifying a mapping locally, for example with Mozilla’s source-map library)

  • sourcesContent contains the original source code Sentry shows next to the stack frame in the UI

If sourcesContent is missing, Sentry can still deminify file names and positions when mappings and sources are present. Sentry then tries other ways to load the original source. If that fails, the issue may show a “Missing Sources Context” banner with no code. For that case, see Why do I see a "Missing Sources Context" error on my issue?.

If stack traces in Sentry look wrong, first confirm the map and minified bundle you upload contain correct mappings, sources, and (when you expect source context) sourcesContent. Then follow the checks in the source maps troubleshooting documentation.

You can also verify a mapping outside Sentry with these tools (not built or maintained by Sentry):

For upload and setup, see the source maps documentation.

Did this answer your question?