Changelog

oven-sh/bun · · 16 commits

Bun tightens streams, fetch, and serve behavior

Major web streams perf work landed alongside fetch proxy fixes and several Bun.serve correctness fixes.

Web Streams got a big performance pass on write, pump, and BYOB paths (robobun5d673d9, robobun539d6c4, robobun280dfbe, robobun423fb8b) These commits reduce per-chunk allocations, add a sync-pull fast path, and serialize type:"direct" pulls on the JS reader path to avoid overlapping async pull() calls. They also improve heap snapshot labeling for stream internals, making stream-related memory leaks and retainer paths much easier to diagnose.

fetch() now re-evaluates proxy settings per redirect hop and accepts URL instances for proxy (robobunb05b4fa, robobun3981e9b) Redirects now re-check http_proxy / https_proxy / NO_PROXY at each hop instead of freezing the original decision, which fixes incorrect proxying across redirected URLs. The proxy option also now properly handles a URL instance in both fetch() and WebSocket, matching the docs and type definitions.

fetch() now rejects on option-conversion errors instead of throwing synchronously (robobune96a4d4) If URL/init coercion or option getters throw, Bun now returns a rejected promise per WHATWG fetch semantics instead of escaping synchronously. This closes a compatibility gap with Node/undici and makes error handling around fetch() much more predictable.

Bun.serve fixed several response-stream and error-handler edge cases (robobun0b489d0, robobundbe00e3, robobun4bfcc0f, robobun124d52c) error() now receives a pending-promise rejection reason of null verbatim, isn’t re-run after the status line is already committed, and can safely return a streaming body. HEAD requests to streaming responses now cancel the body correctly so underlying resources are released instead of leaking.

socket and net writes now treat transient ENOBUFS/ENOMEM as would-block (robobunfc865b3) Transient kernel send failures no longer become fatal connection errors; Bun keeps buffered bytes and retries later. That brings node:net behavior closer to expectations under resource pressure and fixes a class of flaky write failures.

Other misc changes

  • child_process.stdin stays null after exit for non-পiped stdio configs.
  • util.parseArgs() now treats null top-level boolean flags as absent.
  • Build script --help TDZ ReferenceError fix.
  • GC/heap-analysis plumbing and stream internal refactors.
  • Socket callback lifetime/GC refactor and related internal cleanup.