node-sdk icon indicating copy to clipboard operation
node-sdk copied to clipboard

Support the Bun.js Runtime

Open wmluke opened this issue 3 months ago • 4 comments

I would be nice to support the bun.js runtime, but we'll first need to wait for these bun.js issues to be addressed:

  • https://github.com/oven-sh/bun/issues/14498
  • https://github.com/oven-sh/bun/issues/4145

wmluke avatar Oct 17 '25 15:10 wmluke

+1

RainyPixel avatar Oct 30 '25 12:10 RainyPixel

main blocker AFAICT is https://github.com/oven-sh/bun/issues/4474 as we rely on passing a custom Dispatcher to manage the underlying socket

ndeloof avatar Nov 02 '25 10:11 ndeloof

it seems bun just ignores undici agent (https://github.com/oven-sh/bun/issues/10642) which we rely on to support various transport protocols. Support for unix domain socket is available using non-standard 🤨 RequestInit.unix attribute (https://bun.com/docs/guides/http/fetch-unix) and I can get most tests (see next) to pass using this hack. We could also pass custom TLS certificates (https://bun.com/docs/runtime/networking/fetch#tls). We would still miss support for windows npipe and ssh. Sounds like a hack anyway, not sane foundations to work with IMHO 😖

bun overrides undici dependency with a custom implementation 🤪, basically just forwarding to the internal fetch API which is missing upgrade support:

error: This function is not yet implemented in Bun
      at notImplemented (undici:13:14)
      at upgrade (undici:124:17)

this is not strictly needed as engine will accept a plain POST request, but could be required by proxies in some context

ndeloof avatar Nov 02 '25 17:11 ndeloof

tested a (partial) and hack-ish support for bun: https://github.com/docker/node-sdk/pull/59 tests failing for weird reason

ndeloof avatar Nov 03 '25 15:11 ndeloof