Socket
Socket
Sign inDemoInstall

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.1.1 to 4.1.2

6

History.md
4.1.2 / 2020-04-25
==================
**fixes**
* [[`de66b02`](http://github.com/node-modules/agentkeepalive/commit/de66b0206d064a97129c2c31bcdabd4d64557b91)] - fix: detect http request timeout handler (#88) (fengmk2 <<fengmk2@gmail.com>>)
4.1.1 / 2020-04-25

@@ -3,0 +9,0 @@ ==================

30

lib/agent.js

@@ -21,2 +21,11 @@ 'use strict';

// node <= 10
let defaultTimeoutListenerCount = 1;
const majorVersion = parseInt(process.version.split('.', 1)[0].substring(1));
if (majorVersion >= 11 && majorVersion <= 12) {
defaultTimeoutListenerCount = 2;
} else if (majorVersion >= 13) {
defaultTimeoutListenerCount = 3;
}
class Agent extends OriginalAgent {

@@ -283,6 +292,19 @@ constructor(options) {

function onTimeout() {
// onTimeout and emitRequestTimeout(_http_client.js)
// https://github.com/nodejs/node/blob/v12.x/lib/_http_client.js#L711
const listenerCount = socket.listeners('timeout').length;
debug('%s(requests: %s, finished: %s) timeout after %sms, listeners %s',
// node <= 10, default listenerCount is 1, onTimeout
// 11 < node <= 12, default listenerCount is 2, onTimeout and emitRequestTimeout
// node >= 13, default listenerCount is 3, onTimeout,
// onTimeout(https://github.com/nodejs/node/pull/32000/files#diff-5f7fb0850412c6be189faeddea6c5359R333)
// and emitRequestTimeout
const timeout = getSocketTimeout(socket);
const req = socket._httpMessage;
const reqTimeoutListenerCount = req && req.listeners('timeout').length || 0;
debug('%s(requests: %s, finished: %s) timeout after %sms, listeners %s, defaultTimeoutListenerCount %s, hasHttpRequest %s, HttpRequest timeoutListenerCount %s',
socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT],
getSocketTimeout(socket), listenerCount);
timeout, listenerCount, defaultTimeoutListenerCount, !!req, reqTimeoutListenerCount);
if (debug.enabled) {
debug('timeout listeners: %s', socket.listeners('timeout').map(f => f.name).join(', '));
}
agent.timeoutSocketCount++;

@@ -307,6 +329,6 @@ const name = agent.getName(options);

// free socket and timeout happen in the same time.
if (listenerCount === 1) {
if (reqTimeoutListenerCount === 0) {
const error = new Error('Socket timeout');
error.code = 'ERR_SOCKET_TIMEOUT';
error.timeout = getSocketTimeout(socket);
error.timeout = timeout;
// must manually call socket.end() or socket.destroy() to end the connection.

@@ -313,0 +335,0 @@ // https://nodejs.org/dist/latest-v10.x/docs/api/net.html#net_socket_settimeout_timeout_callback

13

package.json
{
"name": "agentkeepalive",
"version": "4.1.1",
"version": "4.1.2",
"description": "Missing keepalive http.Agent",

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

"scripts": {
"test": "npm run lint && egg-bin test",
"test-local": "egg-bin test",
"cov": "egg-bin cov",
"test": "npm run lint && egg-bin test --full-trace",
"test-local": "egg-bin test --full-trace",
"cov": "cross-env DEBUG=agentkeepalive egg-bin cov --full-trace",
"ci": "npm run lint && npm run cov",

@@ -46,2 +46,3 @@ "lint": "eslint lib test index.js",

"coffee": "^5.3.0",
"cross-env": "^6.0.3",
"egg-bin": "^4.9.0",

@@ -59,2 +60,6 @@ "egg-ci": "^1.10.0",

"ci": {
"type": "github",
"os": {
"github": "linux"
},
"version": "8, 10, 12"

@@ -61,0 +66,0 @@ },

# agentkeepalive
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Appveyor status][appveyor-image]][appveyor-url]
[![Test coverage][codecov-image]][codecov-url]
[![David deps][david-image]][david-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]

@@ -13,10 +9,2 @@ [![npm download][download-image]][download-url]

[npm-url]: https://npmjs.org/package/agentkeepalive
[travis-image]: https://img.shields.io/travis/node-modules/agentkeepalive.svg?style=flat
[travis-url]: https://travis-ci.org/node-modules/agentkeepalive
[appveyor-image]: https://ci.appveyor.com/api/projects/status/k7ct4s47di6m5uy2?svg=true
[appveyor-url]: https://ci.appveyor.com/project/fengmk2/agentkeepalive
[codecov-image]: https://codecov.io/gh/node-modules/agentkeepalive/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/node-modules/agentkeepalive
[david-image]: https://img.shields.io/david/node-modules/agentkeepalive.svg?style=flat
[david-url]: https://david-dm.org/node-modules/agentkeepalive
[snyk-image]: https://snyk.io/test/npm/agentkeepalive/badge.svg?style=flat-square

@@ -23,0 +11,0 @@ [snyk-url]: https://snyk.io/test/npm/agentkeepalive

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc