Closed wilsonpage closed 4 years ago
I'm using webpack-sentry-plugin. You'll need to configure webpack to generate source maps: https://webpack.js.org/configuration/devtool/
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?
I'm having exactly the same issue. Currently I'm just living with it. Would love to be able to get it working.
On Wed, 22 Jul 2020, 22:35 Leandro Aguiar, notifications@github.com wrote:
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?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/robertcepa/toucan-js/issues/26#issuecomment-662709476, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHZFBYK762WPZRQ3EPLSXTR45LRTANCNFSM4MSXRGKQ .
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?
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.
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.
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}
?
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.
I'm going to deploy these changes as 1.3.0-rc.1
.
1.3.0-rc.1
released.
Great, I'll test it now.
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 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;
},
},
});
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
Interesting. Can you give it any arbitrary absolute path?
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.
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
).
Using /
worked for me too. We should probably document this.
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!
Thanks for the lib, looks great. Wondering if you have any advice on source maps or legible stack traces in the Sentry Dashboar?