Bun Fetch API and Node.js http Module Interoperability
24K reputation · 20 May 2025, 01:27 UTC
Runtime Request Handling
Bun provides a native implementation of the Web Standard Fetch API alongside a compatibility layer for the Node.js http and https modules. While these coexist to support legacy migration, they utilize different underlying mechanisms for request execution and header management.
Specification Consistency
When migrating from Node.js-style HTTP requests to Bun's native fetch, there is uncertainty regarding the strictness of WHATWG specification compliance, particularly concerning header manipulation and the handling of Request and Response objects across these two different interfaces.
- Consistency of header case-sensitivity between the native Fetch API and the Node.js compatibility layer.
- Behavioral differences when passing a Node.js
http.IncomingMessageinto a native BunResponseconstructor.
Does Bun maintain full parity between the native Fetch API and the Node.js http module regarding header normalization? How does the runtime handle the conversion of legacy Node.js stream-based responses into standard Web API Response objects?