undici
The HTTP/1.1 client that powers Node.js's native fetch(). undici is the official Node.js HTTP client written from scratch for performance — no legacy http.ClientRequest overhead. Provides connection pooling, pipelining, WebSocket, and a fetch-compatible API. Used directly when maximum HTTP throughput is needed or when controlling connection pools explicitly in high-performance Node.js agents.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
Official Node.js project with strong security review. TLS enforced. No third-party dependencies. Part of Node.js core security review process.
⚡ Reliability
Best When
You need maximum HTTP throughput in Node.js with explicit connection pool control, or you want the same HTTP engine that powers Node.js native fetch.
Avoid When
You need ergonomic high-level features like automatic retries and pagination — use Got or axios instead.
Use Cases
- • Build high-throughput HTTP clients for agent data pipelines using undici's connection pool for parallel requests with shared connections
- • Use as the underlying HTTP transport in frameworks and libraries where raw performance matters more than high-level ergonomics
- • Implement mock interceptors for testing without network calls using undici's built-in MockAgent that intercepts at the pool level
- • Control HTTP connection pooling explicitly — set maxConcurrency, connections, and pipelining for fine-tuned agent HTTP behavior
- • Build WebSocket clients with undici's WebSocket class for agent real-time communication (undici WebSocket added in Node.js 21)
Not For
- • High-level HTTP client work — use Got, axios, or ky for retry logic, pagination helpers, and ergonomic request building
- • Older Node.js versions — undici requires Node.js 18+; use Got 11 or axios for Node.js 14/16
- • Browser-side code — undici is Node.js only; use native browser fetch for browser environments
Interface
Authentication
No built-in auth — HTTP client only. Authentication passed via request headers.
Pricing
undici is open source, MIT licensed, and developed under the Node.js project.
Agent Metadata
Known Gotchas
- ⚠ undici Pool reuses connections aggressively — if a server closes connections unexpectedly, SocketError is thrown; implement retry logic for connection reset errors
- ⚠ Response body must be consumed or destroyed — failing to read response.body causes connection to stall and the pool to deadlock for pipelined requests
- ⚠ undici.fetch() is not identical to browser fetch — some edge cases in the Fetch spec are handled differently; test thoroughly if migrating from node-fetch
- ⚠ MockAgent intercepts at the Client level — set up interceptors before creating the Client, not after; order matters for mock matching
- ⚠ Timeouts in undici are body/connect/headers separately — bodyTimeout default is 300s which may be too long for agent pipelines with streaming responses
- ⚠ Connection pool maxConcurrency defaults to unlimited — set explicit limits to prevent overwhelming target servers in agent batch processing scenarios
Alternatives
Full Evaluation Report
Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for undici.
Scores are editorial opinions as of 2026-03-06.