-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix(node): Use normal require
call to import Undici
#10388
Conversation
87bece1
to
1aaeb2e
Compare
@@ -106,7 +105,7 @@ export class Undici implements Integration { | |||
let ds: DiagnosticsChannel | undefined; | |||
try { | |||
// eslint-disable-next-line @typescript-eslint/no-var-requires | |||
ds = dynamicRequire(module, 'diagnostics_channel') as DiagnosticsChannel; | |||
ds = require('diagnostics_channel') as DiagnosticsChannel; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One reason this is there is because diagnostics_channel
is only available for Node 16+, won't bundling break when bundling for older versions? (Like Node 14).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see it as follows: Every bundler has a built-in escape hatch because diagnostics_channel
can always be manually externalized. The newer (sane) webpack versions automatically seem to externalize it out of the box, even on older Node.js versions.
Right now dynamicRequire
seems to break fetch instrumentation on the Next.js canary: https://github.com/getsentry/sentry-javascript/actions/runs/7713179805/job/21023035517
With this change, it succeeds: https://github.com/getsentry/sentry-javascript/actions/runs/7712921252/job/21022104165
dynamicRequire
effectively breaks bundled code. I see this more as a fix I think.
I have the soft opinion that this change is the lesser evil but I am not totally sure tbh. People affected would be people who are on old node versions && on old webpack versions. Wdyt?
I need to dwell on this for a bit. For some reason this doesn't even fix the issue I wanted to fix with this change: https://github.com/getsentry/sentry-javascript/actions/runs/7697605293/job/20975482956 🤔 |
size-limit report 📦
|
dd452b6
to
3847840
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with making this change as long as we update troubleshooting docs accordingly.
I will merge this as soon as I have troubleshooting docs merged. Docs code freeze is in place right now tho. |
Dynamic require will work agains us in bundled server-side situations - e.g. Next.js. We are in Node.js world so
require
should be available in any case. We also use it in the normalhttp
andhttps
instrumentation.