Sourcemap Encoding Issue

We’ve recently started using Sentry, and are generating sourcemaps using Grunt (grunt-contrib-concat and grunt-contrib-uglify). The sourcemaps work fine in practice, but Sentry and throw errors saying the maps aren’t encoded properly.

Inside Sentry, the error shown is “Source file was not ‘utf8’ encoding” for our main JS file, app.js. However, running file -I on our confirms that it’s text/plain; charset=utf-8. provides a bit more information, but it looks like all the errors are coming from third-party libraries we have embedded inside app.js, like Underscore.js (example). The error comes from Underscore’s micro-templating module (_.template), which has to handle character escaping.

So, it appears that there may be two conflating issues that’re preventing Sentry from validating/using our sourcemaps: First, the JS file itself may or may not be encoded as UTF-8. All signs point towards it having the proper encoding, but it’s entirely possible that Grunt or AWS Cloudfront are messing with that somehow. On the other hand, it looks like Sentry / get tripped up when parsing certain Javascript escape characters.

We’d love to get sourcemaps working inside Sentry—the stack traces are super useful, but we still have to map minified to un-minified code manually at this point. Thanks for any help or advice!

I just need to make our encoding check less strict is my guess. It’s probably valid ascii, but we’re throwing it away since it’s not explicitly saying it’s utf-8 when ascii is a safe subset.