Can't use sourcemaps/artifacts

I’m building, minifying and generating sourcemaps of my app with webpack. Artifacts are sent to sentry.io with webpack-sentry-plugin.

The javascript code is run from localhost:8080/js/app.js. It contains //# sourceMappingURL=app.js.map at the end. Sourcemaps work correctly at Chrome devtools.

Sentry’s Releases/Artifacts page shows the following files:

js/app.js
js/app.js.map

Anyway, when Sentry logs an error, stacktrace is from the minified file. It’s not using the sourcemaps.

What am I doing wrong in my setup? Or what other info should I give to get help?

Thanks in advance! :slight_smile:

You need to name your artifacts either like so:

http://localhost:8080/js/app.js
http://localhost:8080/js/app.js.map

Or you can omit the protocol, hostname and port with the tilde (~) prefix:

~/js/app.js
~/js/app.js.map

Awesome! Thank you @benvinegar. It worked! I did read that in the docs multiple times but couldn’t realize it was talking exactly about this situation.

@benvinegar kudos to the awesome work! I see that you are responding promptly to the queries posted in the forum.

We have a similar setup and we have done as you suggested. But the issue that we are facing is there is an extra /js prefixed to the path. Instead of localhost/js/index.js.map sentry is looking for localhost/js/js/index.js.map

Sentry’s Releases/Artifacts page has the following files:

~/js/index.js
~/js/index.js.map

localhost/js/index.js.map would return 404 and that is the expected behaviour as we don’t want the map to be available and hence uploading it to sentry.

Where do you see the path being prefixed? It sounds like you are having a reference in your min.js file that is js/index.js.map instead of /js/index.js.map or just index.js.map. If you use sentry-cli it should also upload the minified files and auto detect the reference.

When we login to sentry, we get the following error

HTTP returned 404 response on localhost/js/js/index.js.map

This is what we have in the source file.

//# sourceMappingURL=index.js.map

We are using sentry-cli to upload the files and the command is as follows

$ sentry-cli releases files <release> upload-sourcemaps ./dist

The content of dist folder is as follows

dist
  |- js
  |  |- index.js
  |  |- index.js.map

I forgot to mention that we have cloudfront cdn serving the sources. So localhost -> cloudfrontURL
Hope the above information is useful.

sentry-cli can only establish links if you also upload the minified files. Since you don’t do that it falls back to fetching. Normally when you upload a foo.min.js we will set up a link from there to foo.js.map for instance. Is foo.js in this case the minified file? I do wonder if the detection gets wrong.

Can you paste the output of the sentry-cli upload?

index.js is the minified file. Do I have to have .min for it to work ?

Should not. Can you paste the output from the upload?

[DEBUG] sentry_cli::commands::releases found: ./dist/js/index.js (2171254 bytes)
[DEBUG] sentry_cli::commands::releases found: ./dist/js/index.js.map (7192528 bytes)
[INFO] sentry_cli::api request POST https://sentry.io/api/0/projects/org/proj/releases/
[INFO] sentry_cli::api using token authentication
[INFO] sentry_cli::api sending JSON data (48 bytes)
[INFO] sentry_cli::api response: 208
[DEBUG] sentry_cli::api headers:
[DEBUG] sentry_cli::api   Server: nginx/1.11.10
[DEBUG] sentry_cli::api   Date: Wed, 29 Mar 2017 18:13:28 GMT
[DEBUG] sentry_cli::api   Content-Type: application/json
[DEBUG] sentry_cli::api   Content-Length: 352
[DEBUG] sentry_cli::api   Connection: keep-alive
[DEBUG] sentry_cli::api   X-XSS-Protection: 1; mode=block
[DEBUG] sentry_cli::api   Content-Language: en
[DEBUG] sentry_cli::api   X-Content-Type-Options: nosniff
[DEBUG] sentry_cli::api   Vary: Accept-Language, Cookie
[DEBUG] sentry_cli::api   Allow: GET, POST, HEAD, OPTIONS
[DEBUG] sentry_cli::api   X-Frame-Options: deny
[DEBUG] sentry_cli::api body: {"dateCreated": "2017-03-29T15:50:53.863Z", "lastEvent": "2017-03-29T17:05:14Z", "shortVersion": "20170329154827", "authors": [], "owner": null, "newGroups": 4, "data": {}, "dateReleased": "2017-03-29T15:50:01.261Z", "url": null, "commitCount": 0, "version": "20170329154827", "firstEvent": "2017-03-29T15:50:53.863Z", "dateStarted": null, "ref": null}
Uploading sourcemaps for release 20170329154827
 -> ~/js/index.js.map [sourcemap]
[INFO] sentry_cli::api request POST https://sentry.io/api/0/projects/org/proj/releases/20170329154827/files/
[INFO] sentry_cli::api using token authentication
[INFO] sentry_cli::api sending form data
[INFO] sentry_cli::api response: 201
[DEBUG] sentry_cli::api headers:
[DEBUG] sentry_cli::api   Server: nginx/1.11.10
[DEBUG] sentry_cli::api   Date: Wed, 29 Mar 2017 18:13:33 GMT
[DEBUG] sentry_cli::api   Content-Type: application/json
[DEBUG] sentry_cli::api   Content-Length: 221
[DEBUG] sentry_cli::api   Connection: keep-alive
[DEBUG] sentry_cli::api   X-XSS-Protection: 1; mode=block
[DEBUG] sentry_cli::api   Content-Language: en
[DEBUG] sentry_cli::api   X-Content-Type-Options: nosniff
[DEBUG] sentry_cli::api   Vary: Accept-Language, Cookie
[DEBUG] sentry_cli::api   Allow: GET, POST, HEAD, OPTIONS
[DEBUG] sentry_cli::api   X-Frame-Options: deny
[DEBUG] sentry_cli::api body: {"sha1": "27441528775448283a829863c55112e02fa5a39f", "name": "~/js/index.js.map", "dateCreated": "2017-03-29T18:13:33.364Z", "headers": {"Content-Type": "application/octet-stream"}, "id": "42", "size": 7192528}
  27441528775448283a829863c55112e02fa5a39f  (7192528 bytes)
 -> ~/js/index.js [minified script]
[INFO] sentry_cli::api request POST https://sentry.io/api/0/projects/org/proj/releases/20170329154827/files/
[INFO] sentry_cli::api using token authentication
[INFO] sentry_cli::api sending form data
[INFO] sentry_cli::api response: 201
[DEBUG] sentry_cli::api headers:
[DEBUG] sentry_cli::api   Server: nginx/1.11.10
[DEBUG] sentry_cli::api   Date: Wed, 29 Mar 2017 18:13:34 GMT
[DEBUG] sentry_cli::api   Content-Type: application/json
[DEBUG] sentry_cli::api   Content-Length: 260
[DEBUG] sentry_cli::api   Connection: keep-alive
[DEBUG] sentry_cli::api   X-XSS-Protection: 1; mode=block
[DEBUG] sentry_cli::api   Content-Language: en
[DEBUG] sentry_cli::api   X-Content-Type-Options: nosniff
[DEBUG] sentry_cli::api   Vary: Accept-Language, Cookie
[DEBUG] sentry_cli::api   Allow: GET, POST, HEAD, OPTIONS
[DEBUG] sentry_cli::api   X-Frame-Options: deny
[DEBUG] sentry_cli::api body: {"sha1": "592c38c127dd467463d9248483f468f85e950e24", "name": "~/js/index.js", "dateCreated": "2017-03-29T18:13:34.627Z", "headers": {"Sourcemap": "js/index.js.map", "Content-Type": "application/octet-stream"}, "id": "43", "size": 2171254}
  592c38c127dd467463d9248483f468f85e950e24  (2171254 bytes)
  -> sourcemap: js/index.js.map

And this is the last line of the source file //# sourceMappingURL=index.js.map

Looks like there is a bug in the associations it sets up. I will investigate this. You might be able to get away with --no-sourcemap-reference for now to disable the reference detection.

Thank you @mitsuhiko. Appreciate the effort.

@chetankothari – I’d have to see your source map or if you could link to your sentry.io issue (if you’re a hosted customer).

I will say, I haven’t heard of this error before, and there are a lot of people using source maps, so I suspect something is up either source map or configuration-wise.

This should be resolved with 1.2.0.

1 Like

@benvinegar we are hosting sentry ourselves. And it would be tricky for me to share the sourcemap. However I can try to reproduce and then share the sourcemap with you. I will only be able do that over the weekend.

@mitsuhiko that sounds great. So that means upgrading the cli to 1.2.0 should be enough from my side.

Yes. That’s the theory. Let me know :slight_smile:

Thanks @mitsuhiko. This works for us.

1 Like