添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

I’m having trouble getting Sentry to use Sourcemaps to un-minify / un-transpile my JS source.

I’m running Sentry Server v8.17.0 and RavenJS v3.19.1 and sentry-cli v1.26.1

My sourcemaps cannot be publicly accessible, so I’ve uploaded them using sentry-cli to the host.

While using the application, my js files are accessible via: https://example.com/webpack/<name>-<hash>.chunk.js

These files have the following at the end of the file:
//# sourceMappingURL=<name>.js.map

I’ve tried several different variants for the file prefix when uploading to our self-hosted sentry server that include:
webpack/
~/webpack/
https://example.com/webpack/

Finally, I’ve tried using both using and omitting the --rewrite flag while using sentry-cli but have every time gotten error messages after the upload has completed:

  Minified Scripts
    ~/webpack/<name>-<hash>.chunk.js (sourcemap at <name>.js.map)
      - warning: could not determine a source map reference (Could not auto-detect referenced sourcemap for ~/webpack/<name>-<hash>.chunk.js.)

Similarly, when I list the files the Source Map column is empty in the resulting table.

I’ve seen several posts like this one, but many of them mention errors that are shown in the sentry webUI. I’m not seeing any errors. I’m not seeing any reference to sourcemap in the event.JSON payload reported (nor in the request from the browser).

A particular frame of the stack trace (as reported in the event.json) looks something like:

"function":"<class_name>.<method_name>", "abs_path":"https://example.com/webpack/<name>-<hash>.chunk.js", "module":"webpack/<name>-<hash>.chunk", "filename":"/webpack/<name>-<hash>.chunk.js", "lineno":1, "colno":12343123, "in_app":true

Not sure if that has anything to do with it, but it seems as though the Sentry Server code might be looking for something like that in the json payload.

github.com

getsentry/sentry/blob/5c93fc10da5a09724e72580475c3ccf624e8fd80/src/sentry/utils/javascript.py#L11-L23

  • def has_sourcemap(event):
  • if event.platform != 'javascript':
  • return False
  • data = event.data
  • if 'sentry.interfaces.Exception' not in data:
  • return False
  • exception = data['sentry.interfaces.Exception']
  • for value in exception['values']:
  • stacktrace = value.get('stacktrace', {})
  • for frame in stacktrace.get('frames', []):
  • if 'sourcemap' in frame.get('data', {}):
  • return True
  •