Closed FozzieHi closed 1 week ago
Hey @FozzieHi thanks for the new issue. I'll let @timfish handle taking a look at this, and it's also being tracked under our main umbrella issue for all instrumentation problems: https://github.com/getsentry/sentry-javascript/issues/12806
Handling of native modules needs improving in import-in-the-middle
and I've opened an issue to address this but currently this is just logging a warning when it's encountered and it shouldn't impact @sentry/node
.
Thanks @timfish, if it is just a warning, I'm wondering why it's causing discord.js
to log this out:
WebSocketShard: Compression is enabled but zlib-sync is not installed, falling back to identify compress
I've taken a brief look at the discord.js
code, and it looks like it is affecting this line, which if it's falsy, causes the message to be logged out:
const getZlibSync = lazy(async () => import('zlib-sync').then((mod) => mod.default).catch(() => null));
A fix was release in import-in-the-middle@1.9.1
. Could you try it out and see if it fixes this issue?
You can either delete your lock file and reinstall or npm/yarn update import-in-the-middle
That works, thanks for your help on this! As an aside, do we know why the warning actually affected discord.js
in this instance? If these sort of warnings can cause application issues, shouldn't it be changed to an error?
import-in-the-middle
instruments every ES module and previosly it threw errors when failing to instrument a file which terminates the process and leaves users unable to use the SDK.
We changed import-in-the-middle
to catch these errors with the only downside being that these specific modules cannot be instrumented. For example in your case, the Sentry SDK doesn't instrument zlib-sync
, so it doesn't matter:
Error: 'import-in-the-middle' failed to wrap 'file:///app/node_modules/zlib-sync/index.js'
Catching these errors helps SDK users get on with their work but we still log them as warnings because then users open helpful issues like this one which let us know where import-in-the-middle
might have bugs or need improvement!
Right, but in this case the warning in import-in-the-middle
did cause this variable to somehow become falsy, is it worth opening a new issue on the import-in-the-middle
repo to investigate more?
const getZlibSync = lazy(async () => import('zlib-sync').then((mod) => mod.default).catch(() => null));
If the issue is still reproducible with v1.9.1, I would open a new issue.
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
8.15.0
Framework Version
No response
Link to Sentry event
No response
SDK Setup/Reproduction Example
No response
Steps to Reproduce
Branching off this issue, when running
import-in-the-middle
v1.8.1, I'm getting the following error:This causes this from
discord.js
:It still occurs with
import-in-the-middle
v1.9.0, but as a warning, this is the output with--trace-warnings
enabled:Expected Result
N/A
Actual Result
N/A