@sentry/tracing
does not work with modern yarn
(in PnP mode)
#4076
Labels
@sentry/tracing
does not work with modern yarn
(in PnP mode)
#4076
Package + Version
@sentry/node
: 6.13.3@sentry/tracing
: 6.13.3Version:
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 tracing was silently failing to do anything.The 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.
See: https://yarnpkg.com/advanced/rulebook/#packages-should-only-ever-require-what-they-formally-list-in-their-dependencies
Neither
@sentry/tracing
or@sentry/utils
listmongoose
/mongodb
/pg
/mysql
as dependencies.The reason this fails is:
sentry-javascript/packages/tracing/src/integrations/node/mongo.ts
Lines 122 to 123 in 84a6dc0
Which then delegates to:
sentry-javascript/packages/utils/src/node.ts
Lines 42 to 46 in 84a6dc0
That empty catch actually suppresses this error:
This is going to be tricky to fix because of the long chain of dependencies needing to pass the target dependency along properly.
One possible suggestion to get around this would be to:
sentry-javascript/packages/tracing/src/integrations/node/mongo.ts
Lines 85 to 89 in 84a6dc0
The caller might then do something like:
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.Something similar would need to be done with all the other integrations.
Slightly related: #3172 (different issue on PnP)
The text was updated successfully, but these errors were encountered: