oven-sh/bun

`undici.Agent` is missing `async close()` method

Open

#14,498 opened on Oct 12, 2024

View on GitHub
 (3 comments) (6 reactions) (1 assignee)Rust (90,348 stars) (4,486 forks)batch import
bugconfirmed buggood first issue

Description

What version of Bun is running?

1.1.20+ae1948925

What platform is your computer?

Darwin 23.6.0 arm64 arm

What steps can reproduce the bug?

let Undici = await import("undici")
let agent = new Undici.Agent()
await agent.close()

What is the expected behavior?

On Node 22.9.0 - the last command returns null, no exceptions.

What do you see instead?

On Bun 1.1.20, agent.close is not implemented, so an exception is thrown (somehow crashing the REPL if using it).

> await agent.close()
2 | return await agent.close();;})();
                            ^
TypeError: agent.close is not a function. (In 'agent.close()', 'agent.close' is undefined)

Additional information

This is preventing NodeHttpClient.layerUndici from @effect/platform-node from working, as agent.close is used here:

https://github.com/Effect-TS/effect/blob/main/packages/platform-node/src/internal/httpClientUndici.ts#L27-L31

Thankfully the default client (NodeHttpClient.layer) works just fine as it uses node:http module under the hood.

Contributor guide