-
Notifications
You must be signed in to change notification settings - Fork 25
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
Source maps still don't seem to be working #54
Comments
Your config seems OK to me. Have you tried devtool: source-map? |
I have yes, I can't use that directly though as the output is too large to upload.
Currently I'm getting around this with two different webpack files, one to build and upload the src map and one to just upload the worker code. Works fine. |
|
i've been wrestling with source-maps today too, and I found that I could not get source maps to work with CF Workers + SentryWebpackPlugin + Toucan unless I removed the We're using webpack 5, and wrangler 1.19 and have configured wrangler to treat the project as We configure the SentryWebpackPlugin like this: new SentryWebpackPlugin({
release: gitRevisionPlugin.version(),
include: './dist',
urlPrefix: '/',
org: '***',
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_TOKEN
}) and Toucan like this: new Toucan({
dsn: SENTRY_DSN,
context: event,
allowedHeaders: ['user-agent'],
allowedSearchParams: /(.*)/,
debug: false,
rewriteFrames: {
root: '/'
},
environment: ENV,
release: VERSION,
pkg
}) which means we generate the bundle js and the source map in the dist dir, and both files get uploaded to sentry and then cloudflare on publish. The source maps show up on the release in Sentry but they just would not work until I switched the webpack devtool from Is that expected? I'd love to understand what is going on there. From the README for toucan it seem like that is not normal. |
Match up the release name reported during deploy with the release name reported at run time. This PR lines things up so releases appear in sentry like `web3-api@<semver>` which it automagically parses nicely. We currently we deploy as `<sort git sha>` but we report as `api-<semver>`. see: https://sentry.io/organizations/protocol-labs-it/releases/web3-api%403.5.1/?project=5866408 - `SENTRY_RELEASE` env var is set during the build, and used for both creating the release at build time and on error reports so they get matched up and our sourcemap is used to unravel the stacktrace. - Rename the bundle to be `worker.js` as that is what cloudflare renames (!?) it to on deploy, and errors are reported as coming from `worker.js` in production, so that has to match or else the source map is not applied. - remove the `//# sourceMappingURL=...` link from the end of the js bundle by switching to `devtool: hidden-source-map` in the webpack config. I have no idea whey this is necessary. see: robertcepa/toucan-js#54 (comment) - add commit info to releases in a way that sentry understands, and can match up to our repo with `setCommits: { auto: true }` see: https://github.com/getsentry/sentry-webpack-plugin#optionssetcommits This fixes our double release counting in sentry and make source maps work for _much error readability_! <img width="848" alt="Screenshot 2021-09-29 at 16 24 53" src="https://user-images.githubusercontent.com/58871/135340773-7f321748-4aae-401e-9dc9-c4ae5d19a696.png"> I have also connected up the repo in Sentry so we can see the commits that go in to the release. <img width="364" alt="Screenshot 2021-09-29 at 21 09 37" src="https://user-images.githubusercontent.com/58871/135341267-d67026d7-881f-4f7b-a314-fbc102c75d37.png"> ### Follow on work - We can spare ourselves from cf worker upload errors by just not uploading our 4MB source map as part of deployment. Use the webpack remove files plugin to delete the source map after it has been uploaded to sentry, as we're just not using in cloudflare! would fix #499 see: #506 - Add COMMITSHA and BRANCH env vars, and a `/version` endpoint to report it as nft.storage does. https://github.com/ipfs-shipyard/nft.storage/blob/7102ad5fc06d90a85027e40fa0aece3429b833e7/packages/api/src/index.js#L58-L64 License: (Apache-2.0 AND MIT) Signed-off-by: Oli Evans <oli@tableflip.io>
@olizilla Do you have |
Seems also not working with modules. |
Aye, we just switched to esm modules on cloudflare, and our source maps are no longer showing up on Sentry. |
I got it working with esm by using the 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 Before this change the raw JSON view of an error on Sentry showed that the 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
|
Thanks so much - this fixed the issue for me, too 🙏 I'm building with esbuild (so no webpack plugin as mentioned in docs), so it was additionally necessary for me to set |
This broke again when we upgraded to wrangler v2... still investigating. |
OK! It seems that Cloudflare does it's own bundling of your worker code. For your source map to work you need to disable that new feature in your wrangler.toml by setting 🎩 Hat tip to @hugomrdias for the discovery in nftstorage/nft.storage#2094 |
We also had to revert the rewriteFrames: {
root: '/'
}, |
This should be a solved problem in 3.0.0. Mind giving it a shot? I added starters for various bundlers in https://github.com/robertcepa/toucan-js/tree/master/examples In 3.0.0 you shouldn't need to use |
@robertcepa I updated our project to use Thanks for all your advice. 🙏 |
Followed the guide in the README and the thread but I'm still getting errors when attempting to link to my source map.
Maybe I'm missing or misunderstanding something still?
The text was updated successfully, but these errors were encountered: