{"id":17731,"library":"keep-alive-agent","title":"Keep-Alive HTTP/S Agent","description":"This package provides a basic HTTP and HTTPS connection pooling agent for Node.js, designed to reuse sockets for improved performance by reducing the overhead of establishing new TCP connections. Originally published as version 0.0.1 in December 2012, the package appears to be abandoned, with no significant updates or active development since its initial release. Its primary differentiator was its simplicity, aiming to complement Node.js's default `Agent` rather than replace it. However, the Node.js ecosystem has evolved significantly since then, with native `http.Agent` offering `keepAlive` functionality and more feature-rich, actively maintained alternatives like `agentkeepalive` now widely available. Due to its age and lack of maintenance, it is not recommended for use in modern applications.","status":"abandoned","version":"0.0.1","language":"javascript","source_language":"en","source_url":"git://github.com/ceejbot/keep-alive-agent","tags":["javascript","keep-alive","http","https","agent"],"install":[{"cmd":"npm install keep-alive-agent","lang":"bash","label":"npm"},{"cmd":"yarn add keep-alive-agent","lang":"bash","label":"yarn"},{"cmd":"pnpm add keep-alive-agent","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only. Attempting to import it using ESM syntax will likely fail or cause runtime issues.","wrong":"import { KeepAliveAgent } from 'keep-alive-agent';","symbol":"KeepAliveAgent","correct":"const KeepAliveAgent = require('keep-alive-agent');"},{"note":"The secure agent is a property of the main export, not a separate named export. This package is CommonJS-only.","wrong":"import { Secure } from 'keep-alive-agent';","symbol":"KeepAliveAgent.Secure","correct":"const KeepAliveAgent = require('keep-alive-agent');\nconst agent = new KeepAliveAgent.Secure();"}],"quickstart":{"code":"const http = require('http');\nconst https = require('https');\nconst KeepAliveAgent = require('keep-alive-agent');\n\n// Ensure these environment variables are set for testing\nconst HTTP_HOSTNAME = process.env.TEST_HOSTNAME_HTTP || 'example.com';\nconst HTTPS_HOSTNAME = process.env.TEST_HOSTNAME_HTTPS || 'google.com';\n\nconst httpAgent = new KeepAliveAgent({ maxSockets: 10 });\nconst httpsAgent = new KeepAliveAgent.Secure({ maxSockets: 10 });\n\n// Example using HTTP keep-alive agent\nconst httpOptions = {\n    hostname: HTTP_HOSTNAME,\n    port: 80,\n    path: '/',\n    agent: httpAgent,\n};\n\nhttp.get(httpOptions, (response) => {\n    console.log(`HTTP Status: ${response.statusCode}`);\n    response.pipe(process.stdout);\n}).on('error', (e) => {\n    console.error(`HTTP request error: ${e.message}`);\n});\n\n// Example using HTTPS keep-alive agent\nconst httpsOptions = {\n    hostname: HTTPS_HOSTNAME,\n    port: 443,\n    path: '/',\n    agent: httpsAgent,\n};\n\nhttps.get(httpsOptions, (response) => {\n    console.log(`HTTPS Status: ${response.statusCode}`);\n    response.pipe(process.stdout);\n}).on('error', (e) => {\n    console.error(`HTTPS request error: ${e.message}`);\n});","lang":"javascript","description":"Demonstrates how to initialize and use the `KeepAliveAgent` for both HTTP and HTTPS requests, reusing sockets for multiple connections."},"warnings":[{"fix":"Migrate to Node.js's built-in `http.Agent` with `keepAlive: true` or use actively maintained alternatives like `agentkeepalive` for enhanced features and stability.","message":"This package (v0.0.1 from 2012) is severely outdated and is not compatible with modern Node.js features or best practices. It likely contains unpatched security vulnerabilities and may not function as expected or at all with current Node.js versions (e.g., Node.js 16+).","severity":"breaking","affected_versions":"<=0.0.1"},{"fix":"Do not use this package. Ensure your Node.js runtime is updated to a supported version (Node.js 16 or newer recommended) and use its native `http.Agent` with `keepAlive: true` or a modern alternative like `agentkeepalive`.","message":"Node.js versions prior to 8.0.0 had a potential Denial of Service (DoS) vulnerability (CVE-2019-5739) related to HTTP/S keep-alive connections remaining open for extended periods. This package predates these fixes and would not benefit from the default 5-second `server.keepAliveTimeout` introduced in Node.js 8.0.0.","severity":"gotcha","affected_versions":"<=0.0.1"},{"fix":"Switch to `agentkeepalive` or configure Node.js's native `http.Agent` with appropriate `keepAlive` and `timeout` settings to align client and server expectations.","message":"Using an unmaintained package for network operations can lead to `ECONNRESET` errors due to mismatched client/server connection timeouts. Modern `keep-alive` agents or Node.js's built-in options have better mechanisms to handle these scenarios.","severity":"gotcha","affected_versions":"<=0.0.1"},{"fix":"Replace this package with a well-supported and actively maintained alternative to ensure stability, performance, and security.","message":"There is no community support, bug fixes, or security patches for this abandoned package. Relying on it introduces significant operational risks and technical debt.","severity":"gotcha","affected_versions":"<=0.0.1"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"This package is unlikely to work correctly with modern Node.js. Use `new http.Agent({ keepAlive: true })` or `new (require('agentkeepalive').HttpAgent)()` instead.","cause":"Attempting to use `new KeepAliveAgent()` in an environment where `require('keep-alive-agent')` returned an undefined or invalid value, often due to Node.js version incompatibility or improper module resolution.","error":"TypeError: KeepAliveAgent is not a constructor"},{"fix":"This package is CommonJS-only and fundamentally too old for modern Node.js. Migrate to a modern keep-alive solution that supports ESM, such as `agentkeepalive` or Node.js's built-in `Agent` features.","cause":"Trying to `require()` this CommonJS package within an ES Module (ESM) context in Node.js, or attempting to `import` it with ESM syntax.","error":"ERR_REQUIRE_ESM"},{"fix":"This error is common with older `keep-alive` implementations. Upgrade to `agentkeepalive` (which includes better timeout handling) or ensure your client-side `keepAlive` and `timeout` settings are less than the server's `keepAliveTimeout`.","cause":"The remote server closed the connection prematurely, or the client attempted to write to a socket that was already closed, often due to misconfigured or outdated keep-alive timeout settings.","error":"ECONNRESET"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}