@artilleryio/int-core 2.26.0-3edf11e → 2.26.0-480c63a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/engine_http.js +23 -0
- package/package.json +2 -2
package/lib/engine_http.js
CHANGED
|
@@ -58,6 +58,21 @@ const DEFAULT_AGENT_OPTIONS = {
|
|
|
58
58
|
keepAliveMsec: 1000
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
+
// agentkeepalive defaults `timeout` (active socket inactivity) to a hardcoded
|
|
62
|
+
// floor of 8000ms (Math.max(freeSocketTimeout * 2, 8000)). When a request's
|
|
63
|
+
// origin doesn't send response bytes within 8s, the socket is destroyed with
|
|
64
|
+
// `error.code = 'ERR_SOCKET_TIMEOUT'` regardless of the user's configured
|
|
65
|
+
// `http.timeout`. Mirror `http.timeout` (or top-level `timeout`) into the agent
|
|
66
|
+
// so the YAML config becomes the actual binding constraint.
|
|
67
|
+
function deriveAgentTimeoutMs(scriptConfig) {
|
|
68
|
+
const timeoutSec =
|
|
69
|
+
scriptConfig?.timeout || scriptConfig?.http?.timeout;
|
|
70
|
+
if (typeof timeoutSec !== 'number') return undefined;
|
|
71
|
+
// Never go below the existing 8s floor — preserves current behaviour for
|
|
72
|
+
// users who explicitly configure a smaller http.timeout.
|
|
73
|
+
return Math.max(8000, timeoutSec * 1000);
|
|
74
|
+
}
|
|
75
|
+
|
|
61
76
|
function createAgents(proxies, opts) {
|
|
62
77
|
const agentOpts = Object.assign({}, DEFAULT_AGENT_OPTIONS, opts);
|
|
63
78
|
|
|
@@ -129,6 +144,10 @@ function HttpEngine(script) {
|
|
|
129
144
|
maxSockets: this.maxSockets,
|
|
130
145
|
maxFreeSockets: this.maxSockets
|
|
131
146
|
});
|
|
147
|
+
const agentTimeoutMs = deriveAgentTimeoutMs(script.config);
|
|
148
|
+
if (agentTimeoutMs !== undefined) {
|
|
149
|
+
agentOpts.timeout = agentTimeoutMs;
|
|
150
|
+
}
|
|
132
151
|
|
|
133
152
|
const agents = createAgents(
|
|
134
153
|
{
|
|
@@ -1003,6 +1022,10 @@ HttpEngine.prototype.setInitialContext = function (initialContext) {
|
|
|
1003
1022
|
maxSockets: 1,
|
|
1004
1023
|
maxFreeSockets: 1
|
|
1005
1024
|
});
|
|
1025
|
+
const agentTimeoutMs = deriveAgentTimeoutMs(this.config);
|
|
1026
|
+
if (agentTimeoutMs !== undefined) {
|
|
1027
|
+
agentOpts.timeout = agentTimeoutMs;
|
|
1028
|
+
}
|
|
1006
1029
|
|
|
1007
1030
|
const agents = createAgents(
|
|
1008
1031
|
{
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artilleryio/int-core",
|
|
3
|
-
"version": "2.26.0-
|
|
3
|
+
"version": "2.26.0-480c63a",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@artilleryio/int-commons": "2.22.0-
|
|
7
|
+
"@artilleryio/int-commons": "2.22.0-480c63a",
|
|
8
8
|
"@artilleryio/sketches-js": "^2.1.1",
|
|
9
9
|
"agentkeepalive": "^4.6.0",
|
|
10
10
|
"arrivals": "^2.1.2",
|