Troubleshooting Source Maps

Setting up source maps can be tricky, but it's worth it to get it right. To troubleshoot your source maps set up, you can either:

  1. Use our automated verification tool inside sentry-cli, or
  2. Follow the manual steps listed below

To use the automated verification process, install and configure the Sentry Command Line Interface. Then, use the sourcemaps explain command, calling it with the relevant event ID, found in the top-left corner of the Issue Details page in sentry.io.

For example, "Event ID: c2ad049f":

Image highlighting where to find the ID of an event on Sentry

Copied
sentry-cli sourcemaps explain c2ad049fd9e448ada7849df94575e019

The CLI output should give you useful information about what went wrong with your source maps setup. If it doesn't, let us know by filing an issue on our Sentry CLI repo so we can make it better.

Verify your artifacts are being uploaded to Sentry. You can find them at [Settings] > Projects > Select your project > Source Maps. For Sentry to de-minify your stack traces you must provide both the minified files (for example, app.min.js) and the corresponding source maps.

Bundlers and tools (like tsc) that generate code, often require you to manually set specific options to generate source maps.

If you followed one of our tool-specific guides, verify you configured your tool to emit source maps and that the source maps contain your original source code in the sourcesContent field.

When running JavaScript build tools (like webpack, Vite, ...) in development-mode/watch-mode, the generated code is sometimes incompatible with our source map uploading processes.

We recommend, especially when testing locally, to run a production build to verify your source maps uploading setup.

In the JavaScript files you uploaded to Sentry, search for code that roughly looks like e._sentryDebugIds=e._sentryDebugIds||{}. This code snippet might look different depending on how you process your code.

If this code exists in a bundle, that bundle will be able to be matched to a source file. Every bundle you deploy in your app needs to have this snippet in order to be correctly source mapped.

If your source code does not contain this snippet and you're using a Sentry plugin for your bundler, please check that you are using the latest version and please verify that the plugin is correctly processing your files. Set the debug option to true to print useful degbugging information.

If you're using the Sentry CLI, verify that you're running the inject command before you upload to Sentry and before you deploy your files.

When inspecting the event payload JSON data in Sentry, verify that the events have a debug_meta property. If this property is missing and you already made sure your source files contain debug ID injection snippets, this likely means that you're using an outdated SDK.

We generally recommend upgrading to the latest version, and for source maps to work you need to at least use version 7.47.0.

After you verified your event has a debug_meta property, the next thing to check is whether all frames inside the raw_stacktrace property inside the events have an abs_path property that exactly matches one of the code_file properties inside the debug_meta images.

If a stack frame doesn't match an entry inside debug_meta, make sure that the relevant file contains a debug ID injection snippet.

Sentry expects that source code and source maps in a given release are uploaded to Sentry before errors occur in that release.

If you upload artifacts after an error is captured by Sentry, Sentry will not go back and retroactively apply any source annotations to those errors. Only new errors triggered after the artifact was uploaded will be affected.

We maintain an online validation tool that can be used to test your source maps against your hosted source: sourcemaps.io.

Alternatively, if you are using Sentry CLI to upload source maps to Sentry, you can use the --validate command line option to verify your source maps are correct.

If you find that Sentry is not mapping filename, line, or column mappings correctly, you should verify that your source maps are functioning locally. To do so, you can use Node.js coupled with Mozilla's source-map library.

First, install source-map globally as an npm module:

Copied
npm install -g source-map

Then, write a Node.js script that reads your source map file and tests a mapping. Here's an example:

Copied
var fs = require("fs"),
  path = require("path"),
  sourceMap = require("source-map");

// Path to file that is generated by your build tool (webpack, tsc, ...)
var GENERATED_FILE = path.join(".", "app.min.js.map");

// Line and column located in your generated file (for example, the source
// of the error from your minified file)
var GENERATED_LINE_AND_COLUMN = { line: 1, column: 1000 };

var rawSourceMap = fs.readFileSync(GENERATED_FILE).toString();
new sourceMap.SourceMapConsumer(rawSourceMap).then(function (smc) {
  var pos = smc.originalPositionFor(GENERATED_LINE_AND_COLUMN);

  // You should see something like:
  // { source: 'original.js', line: 57, column: 9, name: 'myfunc' }
  console.log(pos);
});

If you have the same (incorrect) results locally as you do via Sentry, double-check your source map generation configuration.

For an individual artifact, Sentry accepts a max filesize of 40 MB.

Often users hit this limit because they are transmitting source files at an interim build stage. For example, after your bundler has combined all your source files, but before minification has taken place. If possible, send the original source files.

The Sentry API currently only works with source maps and source files that are uploaded as plain text (UTF-8 encoded). If the files are uploaded in a compressed format (for example, gzip), they will be not be interpreted correctly.

If you are using sentry-cli to upload your artifacts, starting with version 2.4.0 you can add the --decompress flag to your sourcemaps upload or files upload commands.

Sometimes build scripts and plugins produce pre-compressed minified files (for example, webpack's compression plugin). In these cases, you'll need to disable such plugins and perform the compression after the generated source maps/source files have been uploaded to Sentry.

Sentry does source map calculation in its workers. This means the workers need access to the files uploaded through the front end. Double check that the cron workers and web workers can read/write files from the same disk.

The Sentry Node.js SDK generally works well with the source-map-support package if you don't already have source maps uploaded to Sentry.

If you are uploading source maps to Sentry or if you are using a Sentry SDK in the browser, your code cannot use the source-map-support package. source-map-support overwrites the captured stack trace in a way that prevents our source map processors from correctly parsing it.

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").