Skip to content

Conversation

@aduh95
Copy link
Contributor

@aduh95 aduh95 commented Apr 6, 2024

In an attempt to bundle only a subset of Undici code, we forgot to take some side-effect.

Fixes: #417
Closes: #449

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`),
]);
Copy link
Contributor

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 🤔

Copy link
Member

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.

Copy link
Contributor Author

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([
Copy link

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.

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using corepack behind corporate proxy and injected certificate

5 participants