You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This looks like an optimisation to prevent sending unrelated files to the callbacks but it prevents lots of files to be sent to the callback, including the ones we need.
If you log the files sent to the Hook, you will notice that require-in-the-middle sends much more files than import-in-the-middle.
If you remove this line if (!baseDir.endsWith(specifiers.get(filename))) continue in import-in-the-middle it works again.
As I'm really not sure if the issue is with dd-trace-js or import-in-the-middle, I'm creating an issue both here and there.
Tracer Version(s)
5.43.0
Node.js Version(s)
22.14.0
Bug Report
Hey and thanks for the hard work,
let's take the example of
express
:dd-trace-js/packages/datadog-instrumentations/src/express.js
Line 104 in fac8988
Here, you add a hook for the
express
integration that should work for all version4.*.*
. It should look for thelib/middleware/query.js
file.This hook will work if both the version matches and the file is present.
Unfortunately, there is a difference between
require-in-the-middle
andimport-in-the-middle
that will prevent this from working.The difference will happen around here:
dd-trace-js/packages/datadog-instrumentations/src/helpers/register.js
Line 96 in fac8988
If you use
cjs
,fullFilename
will beexpress/lib/middleware/query.js
andmoduleName
will beexpress/lib/middleware/query.js
If you use
esm
,fullFilename
will beexpress/lib/middleware/query.js
andmoduleName
will beexpress
This doesn't seem to be an issue with
dd-trace-js
but rather withimport-in-the-middle
.I think the issue is here: https://github.com/nodejs/import-in-the-middle/blob/53a33a9b07799bff815864089a0c072d223df47b/index.js#L147
This looks like an optimisation to prevent sending unrelated files to the callbacks but it prevents lots of files to be sent to the callback, including the ones we need.
If you log the files sent to the
Hook
, you will notice thatrequire-in-the-middle
sends much more files thanimport-in-the-middle
.If you remove this line
if (!baseDir.endsWith(specifiers.get(filename))) continue
inimport-in-the-middle
it works again.As I'm really not sure if the issue is with
dd-trace-js
orimport-in-the-middle
, I'm creating an issue both here and there.Note: this should fix this issue as well: #5092
Related issue in
import-in-the-middle
: nodejs/import-in-the-middle#185Thanks in advance.
Reproduction Code
No response
Error Logs
No response
Tracer Config
No response
Operating System
No response
Bundling
No Bundling
The text was updated successfully, but these errors were encountered: