question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Source maps still don't seem to be working

See original GitHub issue

Followed the guide in the README and the thread but I’m still getting errors when attempting to link to my source map.

Screen Shot 2021-01-12 at 8 34 49 PM

Maybe I’m missing or misunderstanding something still?

addEventListener('fetch', (event) => {
  const sentry = new Toucan({
    dsn: SENTRY_DSN,
    event,
    environment: 'development',
    release: 'pre-release',
    allowedCookies: /(.*)/,
    allowedHeaders: /(.*)/,
    allowedSearchParams: /(.*)/,
    rewriteFrames: {
      root: '/'
    }
  })

  event.respondWith(handleRequest(event, sentry))
})
const SentryWebpackPlugin = require('@sentry/webpack-plugin')

module.exports = {
  entry: './src/index.js',
  target: 'webworker',
  devtool: 'cheap-module-source-map',
  node: {
    fs: 'empty'
  },
  plugins: [
    new SentryWebpackPlugin({
      authToken: 'abc123',
      release: 'pre-release',
      org: 'abc',
      project: '123',
      include: './dist',
      urlPrefix: '/',
    }),
  ],
}

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
olizillacommented, Feb 28, 2022

I got it working with esm by using the rewriteFrames.iteratee property to strip a leading . character from the Stackframe.filename that we were seeing on errors sent from cloudflare to sentry.

rewriteFrames: {
      // strip . from start of the filename ./worker.mjs as set by cloudflare, to make absolute path `/worker.mjs`
      iteratee: (frame) => ({ ...frame, filename: frame.filename.substring(1) })
    },

happy sourcemap’d sentry error from an es module flavour worker

Screenshot 2022-02-25 at 22 01 21 copy

Before this change the raw JSON view of an error on Sentry showed that the filename property would be set to ./worker.js

unhappy sentry errror

  "exception": {
    "values": [
      {
        "type": "Error",
        "value": "A deliberate error!",
        "stacktrace": {
          "frames": [
            {
              "function": "async Object.fetch",
              "filename": "./worker.mjs",
              "abs_path": "./worker.mjs",

If I configure Toucan with rewriteFrames.root: '/' to prepend / to the filename, then Sentry shows, the filename and abs_path as "/./worker.mjs" and the only way to get Sentry to locate the uploaded bundle was to also set the urlPrefix option one uploading the files to Sentry to the same like urlPrefix: ~/./ which seemed kinda gross, but worked… I opted for just stripping the . from ./worker.mjs in the Toucan config as it seemed neater, as it also meant I could avoid specifying the urlPrefix when uploading them as the default is ~/ which works as, i learnt recently:

as ~/ is wildcard matcher for any protocol+host pair. – https://github.com/getsentry/sentry-cli/issues/894#issuecomment-944347277

3reactions
xmflsctcommented, Jan 29, 2022

Seems also not working with modules.

Read more comments on GitHub >

github_iconTop Results From Across the Web

4 Reasons Why Your Source Maps are Broken - Sentry Blog
Missing original source files​​ This likely means that your source map doesn't contain or link to your original source files. Without your ...
Read more >
Source Maps don't seem to be working for production bundle
I'm creating sourcemaps through Webpack by using devtool: 'source-map' . When I create my production build, I get a folder structure like ...
Read more >
Issue with loading sourcemap file when published through ...
I am having issues with sourcemaps uploaded using the NewRelic Upload ... The docs in npm don't seem accurate, One would think that...
Read more >
Should I Use Source Maps in Production? | CSS-Tricks
Typically, source maps are a configuration option from the preprocessor. Here's Babel's options. I believe that with Sass, you don't even have ...
Read more >
Source Maps - Rollbar Docs
Getting started · 1. Raise descriptive errors from JavaScript · 2. Configure the rollbar.js SDK to support source maps · 3. Upload your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found