infinity-agent is a Node.js utility package that provides custom HTTP and HTTPS agents configured with `maxSockets` set to `Infinity`. It effectively mirrors the behavior of Node.js core `http.Agent` and `https.Agent` classes but modifies them to allow an unlimited number of concurrent outgoing requests. This can be critical for high-throughput applications or services that experience `maxSockets` exhaustion with default Node.js agents. The current stable version is 2.0.3. As a wrapper around Node.js core modules, its release cadence tends to be stable, with updates driven by bug fixes or significant changes in Node.js's underlying network modules. A key differentiator is its out-of-the-box support for an unbounded connection pool, requiring minimal configuration to achieve high concurrency without the usual `maxSockets` limitations. It also includes a minor modification to the `addRequest` method that disables `keepAlive` if the agent isn't explicitly configured for it and `maxSockets` is set to `Infinity`, which is a subtle behavioral difference from the standard Node.js agent.
npm install infinity-agentVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `infinity-agent` to perform multiple concurrent HTTP and HTTPS GET requests, leveraging its `maxSockets: Infinity` configuration to manage an unbounded connection pool.
If `keepAlive` is essential, ensure your agent instance is explicitly configured with `keepAlive: true` during instantiation, or consider managing custom agents with specific `maxSockets` values rather than relying solely on `infinity-agent` for full core parity.
Monitor system resources (memory, file descriptors) in high-load environments. Implement rate limiting or backpressure mechanisms at the application level if external services cannot handle the unbounded concurrency, or if system resources become a bottleneck.
Ensure `infinity-agent` is correctly imported and that you are accessing the `globalAgent` property on the `http` or `https` sub-objects. For CommonJS: `const { http, https } = require('infinity-agent'); const agent = http.globalAgent;`While `infinity-agent` manages socket pooling, `socket hang up` often points to the remote server closing connections prematurely or network instability. Review server logs, ensure the remote service can handle sustained connections, and consider implementing robust retry mechanisms with exponential backoff in your client code.
No dependency data recorded yet.