Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any info on source-maps? #26

Closed
wilsonpage opened this issue Apr 28, 2020 · 19 comments
Closed

Any info on source-maps? #26

wilsonpage opened this issue Apr 28, 2020 · 19 comments

Comments

@wilsonpage
Copy link

Thanks for the lib, looks great. Wondering if you have any advice on source maps or legible stack traces in the Sentry Dashboar?

@robertcepa
Copy link
Owner

I'm using webpack-sentry-plugin. You'll need to configure webpack to generate source maps: https://webpack.js.org/configuration/devtool/

@leandro-manifesto
Copy link

leandro-manifesto commented Jul 22, 2020

So, I'm using Rollup and Sentry CLI instead of Webpack to create the bundle and submit the sourcemaps and I can't get Sentry to recognize the stack frames.

My setup generates 2 files in the dist/ folder: worker.js and worker.js.map.

When Cloudflare's runtime generates an error, the filename is always worker.js and I'm suspecting that Sentry doesn't match it to the ~/worker.js file uploaded during release.

I'l try to setup a webpack project later to test if there is any difference.
In the meantime, do you have any thoughts?

@wilsonpage
Copy link
Author

wilsonpage commented Jul 23, 2020 via email

@robertcepa
Copy link
Owner

robertcepa commented Jul 23, 2020

How do you deploy your worker? Are you using wrangler? I haven't tried Rollup to compile Workers but wrangler is using webpack under the hood, which would explain the discrepancy - 2 different compilers will probably give you 2 different outputs. You can compare your Rollout bundle with wrangler's final bundle to verify (diff dist/worker.js worker/script.js)

Are your stack traces in Sentry completely missing, or just showing nonsense?

@robertcepa robertcepa reopened this Jul 23, 2020
@wilsonpage
Copy link
Author

wilsonpage commented Jul 23, 2020

I'm using standalone webpack build and the sentry-webpack-plugin to upload source-maps. Then I use the CF worker deployment api directly to upload the bundle.js. In Sentry it looks like filename in the stack trace is like /worker.js:123 but the uploaded source map is in the Sentry Artifacts under the path ~/worker.js. Unsure if that's the cause, but I feel like they should match in order for Sentry to marry them.

@leandro-manifesto
Copy link

There is no Webpack involved in my setup, I'm using the Sentry CLI to make the release and Cloudflare API to deploy the worker (I didn't like the way wrangler handles the configuration).

I do get the Exception info, but its all mangled.

@leandro-manifesto
Copy link

Looking at the JSON payload from my events I see that the frame property abs_path is worker.js and according to the Source Maps docs that value needs to match the uploaded artifacts exactly.

Could we make buildStackTrace set the abs_path with something like ${configurablePrefix}/${filename}?

@robertcepa
Copy link
Owner

Thanks for this info. Source-maps definitely deserve some love. It looks like both Sentry CLI and sentry-webpack-plugin prepend the path with ~/ by default. We can provide sourceMapUrlPrefix option, which will default to ~/.

I also realized that we should send stack frames reversed, and also provide stack trace in captureMessage too. Let me see if I can fix that tonight.

@robertcepa
Copy link
Owner

I'm going to deploy these changes as 1.3.0-rc.1.

@robertcepa
Copy link
Owner

1.3.0-rc.1 released.

@leandro-manifesto
Copy link

Great, I'll test it now.

@leandro-manifesto
Copy link

It works... but not the default.

Leaving the url prefix as the default ~/ on Toucan and Sentry CLI had no effect, but when I set them both to /opt/router/dist/ it finally recognized the stack frames.

@robertcepa
Copy link
Owner

I added more flexible rewriteFrames option in https://github.com/robertcepa/toucan-js/releases/tag/v1.3.0. You can now use iteratee function which applies any transformation to every frame.

const toucan = new Toucan({
        dsn: VALID_DSN,
        event,
        rewriteFrames: {
          iteratee: (frame) => {
            frame.filename = `/opt/router/${frame.filename}`;

            return frame;
          },
        },
      });

@maciejp-ro
Copy link
Contributor

It works... but not the default.

Leaving the url prefix as the default ~/ on Toucan and Sentry CLI had no effect, but when I set them both to /opt/router/dist/ it finally recognized the stack frames.

I can confirm, switching to absolute paths finally made source maps work for me

@robertcepa
Copy link
Owner

Interesting. Can you give it any arbitrary absolute path?

@leandro-manifesto
Copy link

Seems like that as long as the absolute paths on the stack frames and Sentry's artifacts match it will work, doesn't matter which absolute path.

@maciejp-ro
Copy link
Contributor

maciejp-ro commented Jul 30, 2020

Interesting. Can you give it any arbitrary absolute path?

Seems so, I used /srv/ as URL prefix. The default ~/ may be linked to some logic in Sentry that would match URL in stack trace to uploaded map (I recall suggestion that if the script is http://example.com/js/foo.js, then it should be uploaded as ~/js/foo.js).

@robertcepa
Copy link
Owner

Using / worked for me too. We should probably document this.

@robertcepa
Copy link
Owner

I added Known issues section in README where I documented this problem + some examples to get this working. Thank you everyone for sorting this out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants