Sentry-cli: How does sentry find the correct source map to use?

Created on 15 Feb 2019  路  2Comments  路  Source: getsentry/sentry-cli

I am having trouble getting sentry to recognize source maps I've uploaded using sentry-cli with node js.

I am using babel to generate source files which upon erroring show a directory structure such as,
image

I've checked to ensure that the uploaded files in the created release match the Artifact path exactly that Sentry sees,
image

If I download index.js from the artifacts listing in sentry, it has a sourceMappingURL comment:

//# sourceMappingURL=index.js.map

which should point to the map file.

Does this sourceMappingURL need instead to be /app/srv/routes/index.js.map? Or should it work as specified with the relative path?

Also, does uploading the same artifact a second time in the same release overwrite the previous artifact?

I've tried to figure out how to get babel to generate these fully qualified paths, but so far no luck. I tried inline source mappings but it makes my app files too large to be usable.

Most helpful comment

Ok, finally got it working.

For posterity:

This document helped,
https://docs.sentry.io/platforms/javascript/sourcemaps/troubleshooting/#verify-your-source-maps-are-built-correctly

My uploaded artifacts now have the paths,
image

The paths in my tracebacks were set to,
app:///srv/routes/index.js
by using a beforeSend method I pulled from another issue.

Also it is important to ensure a release is set via the client config,

const Sentry = require('@sentry/node');
const path = require('path');

Sentry.init({
  dsn: config.sentry.url,
  release: process.env.HEROKU_SLUG_COMMIT,
  beforeSend (event) {
    if (
      !event.exception ||
      !event.exception.values ||
      !event.exception.values[0]
    ) {
      return event
    }

    const value = event.exception.values[0]

    if (value.stacktrace && value.stacktrace.frames) {
      const root = process.cwd()
      value.stacktrace.frames.forEach(function (frame) {
        if (frame.filename.startsWith('/')) {
          frame.filename = 'app:///' + path.relative(root, frame.filename)
        }
      })
    }

    return event
  }
})
  • Issue tracker needs to show a release on the right hand side.
  • Clicking that release name needs to take you to a page that shows the artifacts listing.

image

Good luck.

All 2 comments

Ok, finally got it working.

For posterity:

This document helped,
https://docs.sentry.io/platforms/javascript/sourcemaps/troubleshooting/#verify-your-source-maps-are-built-correctly

My uploaded artifacts now have the paths,
image

The paths in my tracebacks were set to,
app:///srv/routes/index.js
by using a beforeSend method I pulled from another issue.

Also it is important to ensure a release is set via the client config,

const Sentry = require('@sentry/node');
const path = require('path');

Sentry.init({
  dsn: config.sentry.url,
  release: process.env.HEROKU_SLUG_COMMIT,
  beforeSend (event) {
    if (
      !event.exception ||
      !event.exception.values ||
      !event.exception.values[0]
    ) {
      return event
    }

    const value = event.exception.values[0]

    if (value.stacktrace && value.stacktrace.frames) {
      const root = process.cwd()
      value.stacktrace.frames.forEach(function (frame) {
        if (frame.filename.startsWith('/')) {
          frame.filename = 'app:///' + path.relative(root, frame.filename)
        }
      })
    }

    return event
  }
})
  • Issue tracker needs to show a release on the right hand side.
  • Clicking that release name needs to take you to a page that shows the artifacts listing.

image

Good luck.

@econner do sourcemaps urls still show as //# sourceMappingURL=index.js.map? or with another correct path?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexregier picture alexregier  路  4Comments

sameoldmadness picture sameoldmadness  路  5Comments

BioPhoton picture BioPhoton  路  3Comments

kkdev163 picture kkdev163  路  5Comments

tclindner picture tclindner  路  3Comments