-
Notifications
You must be signed in to change notification settings - Fork 169
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: correctly set Dispatcher
prototype for ProxyAgent
#451
Conversation
In an attempt to bundle only a subset of Undici code, we forgot to take some side-effect.
import(`undici/lib/dispatcher/dispatcher.js`), | ||
// @ts-expect-error internal module is untyped | ||
import(`undici/lib/dispatcher/proxy-agent.js`), | ||
]); |
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.
Are we doing all that just to reclaim some bytes? It seems a little dangerous 🤔
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.
304000 of them but yes.
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've added tests, hopefully those ensure we'll catch bugs if this hack breaks again in the future.
)) as { default: typeof import('undici').ProxyAgent }; | ||
if (ProxyAgent == null) { | ||
// Doing a deep import here since undici isn't tree-shakeable | ||
const [api, Dispatcher, _ProxyAgent] = await Promise.all([ |
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.
Do these need to be loaded in a particular order?
I would recommend putting them in a separate file and just exposing the ProxyAgent from that file and add a comment on why those files are needed.
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.
No, any order, that's why I'm loading them concurrently.
In an attempt to bundle only a subset of Undici code, we forgot to take some side-effect.
Fixes: #417
Closes: #449