-
Notifications
You must be signed in to change notification settings - Fork 545
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
Make the global dispatcher truly global #1331
Comments
@mcollina I think this is more your area. Wdyt? |
A problem might be compatibility between major versions, but that can be detected by adding some metadata to the For example: global.___undiciGlobalDispatcher = {
version: 5,
dispatcher: Dispatcher
} And have |
I thought quite a lot about this in the last few weeks. I think we could do this. However, we should be extra careful when doing so and validate compatility. @ronag do you think it would be possible to use the Agent from one version of undici in the one inside node core? |
This could solve it nodejs/node#42814. |
Yes. But then we can't break the interface. Ever |
Pretty much. Are we reading for it? |
Yes and no IMHO. This problem could be solved similarly to what we are doing with Fastify plugins. |
The current implementation of the global dispatcher is that it stores within the library the global agent. This works well when the user is directly using
undici
. Still, suppose the user is using a library that internally usesundici
and the user didn't install the exact same version of the library. In that case, the global dispatcher API won't work as the user would expect.To clarify what I think a typical user expects: it should work in the same way as
nock
.nock
does not suffer from this problem because it will always use the same version of Node.js, while forundici
this is not true (yet).Even if it's kinda ugly, I would suggest attaching the global dispatcher to the Node.js's
global
object, so different versions (withing the major possibly) ofundici
can use the same global dispatcher.If this solution is fine for you (or you have a better idea), I can work on it.
The text was updated successfully, but these errors were encountered: