-
Notifications
You must be signed in to change notification settings - Fork 570
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
errors from node:internal leak #3987
Comments
This is not the same, but seems to go under the same line as #3973. Again, don't believe is right but the behaviour seems like expected given how the I'm starting to believe that we should implement a way for |
Sadly I don't see a clear solution. We could either:
|
never use |
Documentation doesn't advice against it. What would be a point of exporting Error classes from the library in the first place if developer is forbidden from using them?
Duplicating dependencies is (controversial) feature of npm that aims to improve robustness. Of course it's irritating when it causes problems, but that happens in more complex projects, usually when objects are passed from one library (with own nested dependency) to another, or when errors are caught after passing though many layers. In the example, |
Exactly. Don't use
To each its own. If someone wants to use them, it have its own uses if you can guarantee it. Anyhow, every single time we are being prescriptive, people complain.
That's the root cause. However this is fundamentally in conflict with the nature of npm. Anyhow, if you would like to send a PR to improve the doc, it's 100% welcomed! |
Bug Description
When importing
undici
(from node_modules) after usingfetch
(nodejs built-in), thenglobalDispatcher
is filled by built-in undici.Therefore using
instanceof errors.UndiciError
is unreliableReproducible By
Expected Behavior
true
would be printed, as error should be instance ofSocketError
that inheritsUndiciError
Logs & Screenshots
Environment
Checked on Node v20.13.1 and v23.5.0 using undici 7.2.0 and 5.28.4, on ubuntu 22.04 and in node:20.13-alpine3.19 container
Context
It seems natural to use
instanceof
, because error classes are exported.npm
allows to have multiple versions ofundici
exported, so it's easy to have built-in undici,node_modules/undici
and undici nested inside node_modules libraries.To make it worse: ResponseStatusCodeError (which is easiest to test) is thrown outside dispatcher, so when I checked it,
instanceof
worked properly.The text was updated successfully, but these errors were encountered: