Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2020-07-11 04:19:53 +0300
committerisaacs <i@izs.me>2020-07-29 21:53:10 +0300
commite46400c9484f5c66a0ba405eeb8c1340594dbf05 (patch)
tree1c3c13d9024752c4b3dc129e2f86c7963544c5a4 /node_modules/agentkeepalive
parent73657ae140810da50847d0ff729ddbab99ba5aac (diff)
update dependencies, refactor config loading to async
This removes a lot of very outdated dependencies, updates many to their modern (usually promisified) versions, and updates (or removes) code to account for the change. Several dependencies have been completely removed, and others a bit shuffled around, so that the node_modules folder can be bundled somewhat more optimally than it would have otherwise.
Diffstat (limited to 'node_modules/agentkeepalive')
-rw-r--r--node_modules/agentkeepalive/History.md6
-rw-r--r--node_modules/agentkeepalive/lib/agent.js57
-rw-r--r--node_modules/agentkeepalive/package.json12
3 files changed, 49 insertions, 26 deletions
diff --git a/node_modules/agentkeepalive/History.md b/node_modules/agentkeepalive/History.md
index 9ea9986e9..b4e411248 100644
--- a/node_modules/agentkeepalive/History.md
+++ b/node_modules/agentkeepalive/History.md
@@ -1,4 +1,10 @@
+4.1.3 / 2020-06-15
+==================
+
+**fixes**
+ * [[`4ba9f9c`](http://github.com/node-modules/agentkeepalive/commit/4ba9f9c844f2a6b8037ce56599d25c69ef054d91)] - fix: compatible with node v12.16.3 (#91) (killa <<killa123@126.com>>)
+
4.1.2 / 2020-04-25
==================
diff --git a/node_modules/agentkeepalive/lib/agent.js b/node_modules/agentkeepalive/lib/agent.js
index 5767abf22..d0294a69f 100644
--- a/node_modules/agentkeepalive/lib/agent.js
+++ b/node_modules/agentkeepalive/lib/agent.js
@@ -85,6 +85,16 @@ class Agent extends OriginalAgent {
// including free socket timeout counter
this.timeoutSocketCount = 0;
this.timeoutSocketCountLastCheck = 0;
+
+ this.on('free', socket => {
+ // https://github.com/nodejs/node/pull/32000
+ // Node.js native agent will check socket timeout eqs agent.options.timeout.
+ // Use the ttl or freeSocketTimeout to overwrite.
+ const timeout = this.calcSocketTimeout(socket);
+ if (timeout > 0 && socket.timeout !== timeout) {
+ socket.setTimeout(timeout);
+ }
+ });
}
get freeSocketKeepAliveTimeout() {
@@ -102,29 +112,22 @@ class Agent extends OriginalAgent {
return this.options.socketActiveTTL;
}
- keepSocketAlive(socket) {
- const result = super.keepSocketAlive(socket);
- // should not keepAlive, do nothing
- if (!result) return result;
-
+ calcSocketTimeout(socket) {
+ /**
+ * return <= 0: should free socket
+ * return > 0: should update socket timeout
+ * return undefined: not find custom timeout
+ */
let freeSocketTimeout = this.options.freeSocketTimeout;
const socketActiveTTL = this.options.socketActiveTTL;
if (socketActiveTTL) {
// check socketActiveTTL
const aliveTime = Date.now() - socket[SOCKET_CREATED_TIME];
const diff = socketActiveTTL - aliveTime;
- // destroy it
if (diff <= 0) {
- debug('%s(requests: %s, finished: %s) free but need to destroy by TTL, alive %sms(max %sms)',
- socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT],
- aliveTime, socketActiveTTL);
- return false;
+ return diff;
}
-
if (freeSocketTimeout && diff < freeSocketTimeout) {
- debug('%s(requests: %s, finished: %s) free and wait for %sms TTL timeout',
- socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT],
- diff);
freeSocketTimeout = diff;
}
}
@@ -134,12 +137,26 @@ class Agent extends OriginalAgent {
// try to use socket custom freeSocketTimeout first, support headers['keep-alive']
// https://github.com/node-modules/urllib/blob/b76053020923f4d99a1c93cf2e16e0c5ba10bacf/lib/urllib.js#L498
const customFreeSocketTimeout = socket.freeSocketTimeout || socket.freeSocketKeepAliveTimeout;
- if (customFreeSocketTimeout && customFreeSocketTimeout < freeSocketTimeout) {
- freeSocketTimeout = customFreeSocketTimeout;
- }
- // FIXME: need to make setRequestSocket as a method on Agent class
- // then we can reset the agent.options.timeout when free socket is reused.
- socket.setTimeout(freeSocketTimeout);
+ return customFreeSocketTimeout || freeSocketTimeout;
+ }
+ }
+
+ keepSocketAlive(socket) {
+ const result = super.keepSocketAlive(socket);
+ // should not keepAlive, do nothing
+ if (!result) return result;
+
+ const customTimeout = this.calcSocketTimeout(socket);
+ if (typeof customTimeout === 'undefined') {
+ return true;
+ }
+ if (customTimeout <= 0) {
+ debug('%s(requests: %s, finished: %s) free but need to destroy by TTL, request count %s, diff is %s',
+ socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT], customTimeout);
+ return false;
+ }
+ if (socket.timeout !== customTimeout) {
+ socket.setTimeout(customTimeout);
}
return true;
}
diff --git a/node_modules/agentkeepalive/package.json b/node_modules/agentkeepalive/package.json
index 85ba8bb8f..b8f8a4a44 100644
--- a/node_modules/agentkeepalive/package.json
+++ b/node_modules/agentkeepalive/package.json
@@ -1,8 +1,8 @@
{
"_from": "agentkeepalive@^4.1.0",
- "_id": "agentkeepalive@4.1.2",
+ "_id": "agentkeepalive@4.1.3",
"_inBundle": false,
- "_integrity": "sha512-waNHE7tQBBn+2qXucI8HY0o2Y0OBPWldWOWsZwY71JcCm4SvrPnWdceFfB5NIXSqE8Ewq6VR/Qt5b1i69P6KCQ==",
+ "_integrity": "sha512-wn8fw19xKZwdGPO47jivonaHRTd+nGOMP1z11sgGeQzDy2xd5FG0R67dIMcKHDE2cJ5y+YXV30XVGUBPRSY7Hg==",
"_location": "/agentkeepalive",
"_phantomChildren": {
"ms": "2.1.2"
@@ -20,8 +20,8 @@
"_requiredBy": [
"/make-fetch-happen"
],
- "_resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.1.2.tgz",
- "_shasum": "d7bc3bafd7ea88032f6be22b6f1389b3d42c9c91",
+ "_resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.1.3.tgz",
+ "_shasum": "360a09d743a1f4fde749f9ba07caa6575d08259a",
"_spec": "agentkeepalive@^4.1.0",
"_where": "/Users/isaacs/dev/npm/cli/node_modules/make-fetch-happen",
"author": {
@@ -39,7 +39,7 @@
"os": {
"github": "linux"
},
- "version": "8, 10, 12"
+ "version": "8, 10, 12, 14"
},
"dependencies": {
"debug": "^4.1.0",
@@ -94,5 +94,5 @@
"test": "npm run lint && egg-bin test --full-trace",
"test-local": "egg-bin test --full-trace"
},
- "version": "4.1.2"
+ "version": "4.1.3"
}