Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

agentkeepalive

Package Overview
Dependencies
Maintainers
4
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

agentkeepalive - npm Package Compare versions

Comparing version 4.0.2 to 4.1.0

9

History.md
4.1.0 / 2019-10-12
==================
**features**
* [[`fe33b80`](http://github.com/node-modules/agentkeepalive/commit/fe33b800acc09109388bfe65107550952b6fc7b0)] - feat: Add `reusedSocket` property on client request (#82) (Weijia Wang <<starkwang@126.com>>)
**others**
* [[`77ba744`](http://github.com/node-modules/agentkeepalive/commit/77ba744667bb6b9e5986a53e5222f62094db12b9)] - docs: fix grammar in readme (#81) (Herrington Darkholme <<2883231+HerringtonDarkholme@users.noreply.github.com>>)
4.0.2 / 2019-02-19

@@ -3,0 +12,0 @@ ==================

2

lib/agent.js

@@ -143,2 +143,4 @@ 'use strict';

const socket = args[0];
const req = args[1];
req.reusedSocket = true;
const agentTimeout = this.options.timeout;

@@ -145,0 +147,0 @@ if (getSocketTimeout(socket) !== agentTimeout) {

2

package.json
{
"name": "agentkeepalive",
"version": "4.0.2",
"version": "4.1.0",
"description": "Missing keepalive http.Agent",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -68,3 +68,3 @@ # agentkeepalive

* `socketActiveTTL` {Number} Sets the socket active time to live, even if it's in use.
If not setted the behaviour continues the same (the socket will be released only when free)
If not set, the behaviour keeps the same (the socket will be released only when free)
Default = `null`.

@@ -169,2 +169,26 @@

### Support `req.reusedSocket`
This agent implements the `req.reusedSocket` to determine whether a request is send through a reused socket.
When server closes connection at unfortunate time ([keep-alive race](https://code-examples.net/en/q/28a8069)), the http client will throw a `ECONNRESET` error. Under this circumstance, `req.reusedSocket` is useful when we want to retry the request automatically.
```js
const http = require('http');
const Agent = require('agentkeepalive');
const agent = new Agent();
const req = http
.get('http://localhost:3000', { agent }, (res) => {
// ...
})
.on('error', (err) => {
if (req.reusedSocket && err.code === 'ECONNRESET') {
// retry the request or anything else...
}
})
```
This behavior is consistent with Node.js core. But through `agentkeepalive`, you can use this feature in older Node.js version.
## [Benchmark](https://github.com/node-modules/agentkeepalive/tree/master/benchmark)

@@ -171,0 +195,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc