Title: `@sentry/tracing` does not work with modern `yarn` (in PnP mode) · Issue #4076 · getsentry/sentry-javascript · GitHub
Open Graph Title: `@sentry/tracing` does not work with modern `yarn` (in PnP mode) · Issue #4076 · getsentry/sentry-javascript
X Title: `@sentry/tracing` does not work with modern `yarn` (in PnP mode) · Issue #4076 · getsentry/sentry-javascript
Description: Package + Version @sentry/node: 6.13.3 @sentry/tracing: 6.13.3 Version: 6.13.3 Description While trying to add tracing instrumentation for mongoose in a nodejs app that uses Yarn 3.0 in PnP mode I noticed that nothing was happening, and ...
Open Graph Description: Package + Version @sentry/node: 6.13.3 @sentry/tracing: 6.13.3 Version: 6.13.3 Description While trying to add tracing instrumentation for mongoose in a nodejs app that uses Yarn 3.0 in PnP mode I ...
X Description: Package + Version @sentry/node: 6.13.3 @sentry/tracing: 6.13.3 Version: 6.13.3 Description While trying to add tracing instrumentation for mongoose in a nodejs app that uses Yarn 3.0 in PnP mode I ...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/4076
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`@sentry/tracing` does not work with modern `yarn` (in PnP mode)","articleBody":"## Package + Version\r\n\r\n- [x] `@sentry/node`: 6.13.3\r\n- [x] `@sentry/tracing`: 6.13.3\r\n\r\n### Version:\r\n\r\n```\r\n6.13.3\r\n```\r\n\r\n## Description\r\n\r\nWhile trying to add tracing instrumentation for `mongoose` in a nodejs app that uses Yarn 3.0 in PnP mode I noticed that nothing was happening, and tracing was silently failing to do anything.\r\n\r\nThe problem is that PnP mode is strict about which dependencies are allowed to be required, and a package that doesn't define the dep in its package.json (dependencies or peerDependencies) will not be able to require it.\r\n\r\nSee: https://yarnpkg.com/advanced/rulebook/#packages-should-only-ever-require-what-they-formally-list-in-their-dependencies\r\n\r\nNeither `@sentry/tracing` or `@sentry/utils` list `mongoose`/`mongodb`/`pg`/`mysql` as dependencies.\r\n\r\nThe reason this fails is:\r\n\r\nhttps://github.com/getsentry/sentry-javascript/blob/84a6dc041567f6b4486183ccabbd078a48225304/packages/tracing/src/integrations/node/mongo.ts#L122-L123\r\n\r\nWhich then delegates to:\r\n\r\nhttps://github.com/getsentry/sentry-javascript/blob/84a6dc041567f6b4486183ccabbd078a48225304/packages/utils/src/node.ts#L42-L46\r\n\r\nThat empty catch actually suppresses this error:\r\n\r\n```\r\nError: @sentry/utils tried to access mongoose (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.\r\n\r\nRequired package: mongoose\r\nRequired by: @sentry/utils@virtual:...\r\n\r\nAncestor breaking the chain: @sentry/core@npm:6.13.3\r\nAncestor breaking the chain: @sentry/hub@npm:6.13.3\r\nAncestor breaking the chain: @sentry/node@npm:6.13.3\r\n```\r\n\r\nThis is going to be tricky to fix because of the long chain of dependencies needing to pass the target dependency along properly.\r\n\r\nOne possible suggestion to get around this would be to:\r\n - make the error clearer to the user\r\n - make it possible to inject the library via the constructor in:\r\n https://github.com/getsentry/sentry-javascript/blob/84a6dc041567f6b4486183ccabbd078a48225304/packages/tracing/src/integrations/node/mongo.ts#L85-L89\r\n \r\n The caller might then do something like:\r\n ```ts\r\n const MongoTracingIntegration = new Tracing.Integrations.Mongo({\r\n collection: require(\"mongoose\").Collection,\r\n });\r\n ```\r\n This would bypass the `require` call being done by the sentry library, and delegate it to the user instead, providing a way around the problem.\r\n\r\nSomething similar would need to be done with all the other integrations.\r\n\r\nSlightly related: https://github.com/getsentry/sentry-javascript/issues/3172 (different issue on PnP)","author":{"url":"https://github.com/andreialecu","@type":"Person","name":"andreialecu"},"datePublished":"2021-10-19T09:03:28Z","url":"https://github.com/getsentry/sentry-javascript/issues/4076"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3ca4a772-e7b4-2c8f-d001-3a8fa4ac6ff0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D7EC:BE8D0:59B1F3:7E2830:6B0475C5 |
| html-safe-nonce | d744d71454d11c749f41ebc0426db77a5a8f965769cb12594066e99909fc89a9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEN0VDOkJFOEQwOjU5QjFGMzo3RTI4MzA6NkIwNDc1QzUiLCJ2aXNpdG9yX2lkIjoiMjEzMTQ4NDA5Nzc1MzkzNzM0OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8bd0a5d4ff0585d2e282ec1affa4d57d0c7577be735e65632efb9e09fa3f1bab |
| hovercard-subject-tag | issue:1030046187 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/4076/issue_layout |
| twitter:image | https://opengraph.githubassets.com/937e721a982facaaccd05e6cbf51997d80c8444faecb2d82fe8907da4f82c327/getsentry/sentry-javascript/issues/4076 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/937e721a982facaaccd05e6cbf51997d80c8444faecb2d82fe8907da4f82c327/getsentry/sentry-javascript/issues/4076 |
| og:image:alt | Package + Version @sentry/node: 6.13.3 @sentry/tracing: 6.13.3 Version: 6.13.3 Description While trying to add tracing instrumentation for mongoose in a nodejs app that uses Yarn 3.0 in PnP mode I ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | andreialecu |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9c099f1b85def81ca352464c276510dfef32deaf3c305404e65b8d270284a58b |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cf73f57448d52b3a7b619195e182b33d3b3454ca |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width