oven-sh/bun

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

Open

#14,498 建立於 2024年10月12日

在 GitHub 查看
 (3 留言) (6 反應) (1 負責人)Rust (90,348 star) (4,486 fork)batch import
bugconfirmed buggood first issue

描述

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.

貢獻者指南