@songtonyli/dsh-cli 0.1.85 → 0.1.87
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/README.md +1 -1
- package/bin/dsh.mjs +1 -1
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/LICENSE +201 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/README.md +9 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-cjs/index.js +859 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/build-abort-error.js +19 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/constants.js +1 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js +12 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/http2/ClientHttp2SessionRef.js +51 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/index.js +3 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +251 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-manager.js +135 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-pool.js +46 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/node-http2-handler.js +180 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/node-http2.js +2 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/node-https.js +2 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/set-connection-timeout.js +36 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/set-request-timeout.js +21 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/set-socket-keep-alive.js +22 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js +23 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/timing.js +4 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-es/write-request-body.js +63 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/package.json +56 -0
- package/node_modules/@deepseek-ai/dsh-client-modules/lib/index.js +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-llm-pi-ai/lib/index.js +39 -52
- package/node_modules/@deepseek-ai/dsh-tui-app/README.i18n.yaml +6 -6
- package/node_modules/@deepseek-ai/dsh-tui-app/README.md +3 -2
- package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +3 -2
- package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +243 -25
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/LICENSE +201 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/README.md +9 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-cjs/index.js +859 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/build-abort-error.js +19 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/constants.js +1 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js +12 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/http2/ClientHttp2SessionRef.js +51 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/index.js +3 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +251 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-manager.js +135 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-pool.js +46 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/node-http2-handler.js +180 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/node-http2.js +2 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/node-https.js +2 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/set-connection-timeout.js +36 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/set-request-timeout.js +21 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/set-socket-keep-alive.js +22 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js +23 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/timing.js +4 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-es/write-request-body.js +63 -0
- package/node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/package.json +56 -0
- package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +13 -37
- package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +44 -29
- package/node_modules/@smithy/core/dist-es/submodules/cbor/SmithyRpcV2CborProtocol.js +12 -37
- package/node_modules/@smithy/core/dist-es/submodules/protocols/AbstractRpcV2Protocol.js +35 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/RpcProtocol.js +4 -1
- package/node_modules/@smithy/core/dist-es/submodules/protocols/index.js +1 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/SmithyRpcV2JsonProtocol.js +8 -31
- package/node_modules/@smithy/core/package.json +1 -1
- package/node_modules/@smithy/node-http-handler/dist-cjs/index.js +48 -6
- package/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +9 -1
- package/node_modules/@smithy/node-http-handler/dist-es/node-http2-handler.js +20 -2
- package/node_modules/@smithy/node-http-handler/dist-es/resolve-default-socket-timeout.js +4 -0
- package/node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js +16 -3
- package/node_modules/@smithy/node-http-handler/package.json +3 -3
- package/node_modules/execa/package.json +1 -1
- package/node_modules/unist-util-visit/lib/index.js +173 -161
- package/node_modules/unist-util-visit/license +1 -1
- package/node_modules/unist-util-visit/package.json +46 -56
- package/node_modules/unist-util-visit/readme.md +87 -27
- package/node_modules/unist-util-visit-parents/lib/color.js +4 -0
- package/node_modules/unist-util-visit-parents/lib/color.node.js +4 -0
- package/node_modules/unist-util-visit-parents/lib/index.js +235 -52
- package/node_modules/unist-util-visit-parents/license +1 -1
- package/node_modules/unist-util-visit-parents/package.json +44 -54
- package/node_modules/unist-util-visit-parents/readme.md +185 -74
- package/package.json +6 -6
|
@@ -1,53 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { NormalizedSchema, TypeRegistry
|
|
3
|
-
import { getSmithyContext } from "@smithy/core/transport";
|
|
1
|
+
import { AbstractRpcV2Protocol } from "@smithy/core/protocols";
|
|
2
|
+
import { NormalizedSchema, TypeRegistry } from "@smithy/core/schema";
|
|
4
3
|
import { CborCodec } from "./CborCodec";
|
|
5
4
|
import { loadSmithyRpcV2CborErrorCode } from "./parseCborBody";
|
|
6
|
-
export class SmithyRpcV2CborProtocol extends
|
|
5
|
+
export class SmithyRpcV2CborProtocol extends AbstractRpcV2Protocol {
|
|
7
6
|
codec = new CborCodec();
|
|
8
7
|
serializer = this.codec.createSerializer();
|
|
9
8
|
deserializer = this.codec.createDeserializer();
|
|
10
|
-
constructor({ defaultNamespace, errorTypeRegistries, }) {
|
|
11
|
-
super({ defaultNamespace, errorTypeRegistries });
|
|
12
|
-
}
|
|
13
9
|
getShapeId() {
|
|
14
10
|
return "smithy.protocols#rpcv2Cbor";
|
|
15
11
|
}
|
|
16
12
|
getPayloadCodec() {
|
|
17
13
|
return this.codec;
|
|
18
14
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (deref(operationSchema.input) === "unit") {
|
|
27
|
-
delete request.body;
|
|
28
|
-
delete request.headers["content-type"];
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
if (!request.body) {
|
|
32
|
-
this.serializer.write(15, {});
|
|
33
|
-
request.body = this.serializer.flush();
|
|
34
|
-
}
|
|
35
|
-
if (request.body instanceof Uint8Array) {
|
|
36
|
-
request.headers["content-length"] = String(request.body.byteLength);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const { service, operation } = getSmithyContext(context);
|
|
40
|
-
const path = `/service/${service}/operation/${operation}`;
|
|
41
|
-
if (request.path.endsWith("/")) {
|
|
42
|
-
request.path += path.slice(1);
|
|
15
|
+
getSmithyProtocolHeaderValue() {
|
|
16
|
+
return "rpc-v2-cbor";
|
|
17
|
+
}
|
|
18
|
+
applyEmptyBody(request) {
|
|
19
|
+
if (!request.body) {
|
|
20
|
+
this.serializer.write(15, {});
|
|
21
|
+
request.body = this.serializer.flush();
|
|
43
22
|
}
|
|
44
|
-
|
|
45
|
-
request.
|
|
23
|
+
if (request.body instanceof Uint8Array) {
|
|
24
|
+
request.headers["content-length"] = String(request.body.byteLength);
|
|
46
25
|
}
|
|
47
|
-
return request;
|
|
48
|
-
}
|
|
49
|
-
async deserializeResponse(operationSchema, context, response) {
|
|
50
|
-
return super.deserializeResponse(operationSchema, context, response);
|
|
51
26
|
}
|
|
52
27
|
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
53
28
|
const errorIdentifier = loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { deref } from "@smithy/core/schema";
|
|
2
|
+
import { getSmithyContext } from "@smithy/core/transport";
|
|
3
|
+
import { RpcProtocol } from "./RpcProtocol";
|
|
4
|
+
export class AbstractRpcV2Protocol extends RpcProtocol {
|
|
5
|
+
constructor({ defaultNamespace, errorTypeRegistries, }) {
|
|
6
|
+
super({ defaultNamespace, errorTypeRegistries });
|
|
7
|
+
}
|
|
8
|
+
async serializeRequest(operationSchema, input, context) {
|
|
9
|
+
const request = await super.serializeRequest(operationSchema, input, context);
|
|
10
|
+
Object.assign(request.headers, {
|
|
11
|
+
"content-type": this.getDefaultContentType(),
|
|
12
|
+
"smithy-protocol": this.getSmithyProtocolHeaderValue(),
|
|
13
|
+
accept: this.getDefaultContentType(),
|
|
14
|
+
});
|
|
15
|
+
if (deref(operationSchema.input) === "unit") {
|
|
16
|
+
delete request.body;
|
|
17
|
+
delete request.headers["content-type"];
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
this.applyEmptyBody(request);
|
|
21
|
+
}
|
|
22
|
+
const { service, operation } = getSmithyContext(context);
|
|
23
|
+
const path = `/service/${service}/operation/${operation}`;
|
|
24
|
+
if (request.path.endsWith("/")) {
|
|
25
|
+
request.path += path.slice(1);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
request.path += path;
|
|
29
|
+
}
|
|
30
|
+
return request;
|
|
31
|
+
}
|
|
32
|
+
isErrorResponse(statusCode) {
|
|
33
|
+
return statusCode !== 200;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -59,7 +59,7 @@ export class RpcProtocol extends HttpProtocol {
|
|
|
59
59
|
const deserializer = this.deserializer;
|
|
60
60
|
const ns = NormalizedSchema.of(operationSchema.output);
|
|
61
61
|
const dataObject = {};
|
|
62
|
-
if (response.statusCode
|
|
62
|
+
if (this.isErrorResponse(response.statusCode)) {
|
|
63
63
|
const bytes = await collectBody(response.body, context);
|
|
64
64
|
if (bytes.byteLength > 0) {
|
|
65
65
|
Object.assign(dataObject, await deserializer.read(15, bytes));
|
|
@@ -91,4 +91,7 @@ export class RpcProtocol extends HttpProtocol {
|
|
|
91
91
|
dataObject.$metadata = this.deserializeMetadata(response);
|
|
92
92
|
return dataObject;
|
|
93
93
|
}
|
|
94
|
+
isErrorResponse(statusCode) {
|
|
95
|
+
return statusCode >= 300;
|
|
96
|
+
}
|
|
94
97
|
}
|
|
@@ -3,6 +3,7 @@ export { extendedEncodeURIComponent } from "./extended-encode-uri-component";
|
|
|
3
3
|
export { HttpBindingProtocol } from "./HttpBindingProtocol";
|
|
4
4
|
export { HttpProtocol } from "./HttpProtocol";
|
|
5
5
|
export { RpcProtocol } from "./RpcProtocol";
|
|
6
|
+
export { AbstractRpcV2Protocol } from "./AbstractRpcV2Protocol";
|
|
6
7
|
export { RequestBuilder, requestBuilder } from "./requestBuilder";
|
|
7
8
|
export { resolvedPath } from "./resolve-path";
|
|
8
9
|
export { FromStringShapeDeserializer } from "./serde/FromStringShapeDeserializer";
|
package/node_modules/@smithy/core/dist-es/submodules/protocols/json/SmithyRpcV2JsonProtocol.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { NormalizedSchema, TypeRegistry
|
|
3
|
-
import { getSmithyContext } from "@smithy/core/transport";
|
|
1
|
+
import { AbstractRpcV2Protocol } from "../AbstractRpcV2Protocol";
|
|
2
|
+
import { NormalizedSchema, TypeRegistry } from "@smithy/core/schema";
|
|
4
3
|
import { JsonCodec2 } from "./codec-v2/JsonCodec2";
|
|
5
4
|
import { loadSmithyRpcV2JsonErrorCode } from "./parseJsonBody";
|
|
6
|
-
export class SmithyRpcV2JsonProtocol extends
|
|
5
|
+
export class SmithyRpcV2JsonProtocol extends AbstractRpcV2Protocol {
|
|
7
6
|
codec = new JsonCodec2({
|
|
8
7
|
timestampFormat: {
|
|
9
8
|
useTrait: false,
|
|
@@ -14,41 +13,19 @@ export class SmithyRpcV2JsonProtocol extends RpcProtocol {
|
|
|
14
13
|
});
|
|
15
14
|
serializer = this.codec.createSerializer();
|
|
16
15
|
deserializer = this.codec.createDeserializer();
|
|
17
|
-
constructor({ defaultNamespace, errorTypeRegistries, }) {
|
|
18
|
-
super({ defaultNamespace, errorTypeRegistries });
|
|
19
|
-
}
|
|
20
16
|
getShapeId() {
|
|
21
17
|
return "smithy.protocols#rpcv2Json";
|
|
22
18
|
}
|
|
23
19
|
getPayloadCodec() {
|
|
24
20
|
return this.codec;
|
|
25
21
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
accept: this.getDefaultContentType(),
|
|
32
|
-
});
|
|
33
|
-
if (deref(operationSchema.input) === "unit") {
|
|
34
|
-
delete request.body;
|
|
35
|
-
delete request.headers["content-type"];
|
|
36
|
-
}
|
|
37
|
-
else if (!request.body) {
|
|
22
|
+
getSmithyProtocolHeaderValue() {
|
|
23
|
+
return "rpc-v2-json";
|
|
24
|
+
}
|
|
25
|
+
applyEmptyBody(request) {
|
|
26
|
+
if (!request.body) {
|
|
38
27
|
request.body = "{}";
|
|
39
28
|
}
|
|
40
|
-
const { service, operation } = getSmithyContext(context);
|
|
41
|
-
const path = `/service/${service}/operation/${operation}`;
|
|
42
|
-
if (request.path.endsWith("/")) {
|
|
43
|
-
request.path += path.slice(1);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
request.path += path;
|
|
47
|
-
}
|
|
48
|
-
return request;
|
|
49
|
-
}
|
|
50
|
-
async deserializeResponse(operationSchema, context, response) {
|
|
51
|
-
return super.deserializeResponse(operationSchema, context, response);
|
|
52
29
|
}
|
|
53
30
|
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
54
31
|
const errorName = loadSmithyRpcV2JsonErrorCode(response, dataObject) ?? "Unknown";
|
|
@@ -123,13 +123,26 @@ const setSocketKeepAlive = (request, { keepAlive, keepAliveMsecs }, deferTimeMs
|
|
|
123
123
|
return timing.setTimeout(registerListener, deferTimeMs);
|
|
124
124
|
};
|
|
125
125
|
|
|
126
|
+
const resolveDefaultSocketTimeout = (config) => {
|
|
127
|
+
const value = config?.defaultSocketTimeout;
|
|
128
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : undefined;
|
|
129
|
+
};
|
|
130
|
+
|
|
126
131
|
const DEFER_EVENT_LISTENER_TIME = 3000;
|
|
127
|
-
const setSocketTimeout = (request, reject, timeoutInMs = 0) => {
|
|
132
|
+
const setSocketTimeout = (request, reject, timeoutInMs = 0, destroyResponseBodyOnTimeout = false) => {
|
|
133
|
+
let response;
|
|
134
|
+
if (destroyResponseBodyOnTimeout) {
|
|
135
|
+
request.once("response", (res) => (response = res));
|
|
136
|
+
}
|
|
128
137
|
const registerTimeout = (offset) => {
|
|
129
138
|
const timeout = timeoutInMs - offset;
|
|
130
139
|
const onTimeout = () => {
|
|
140
|
+
const error = Object.assign(new Error(`@smithy/node-http-handler - the request socket timed out after ${timeoutInMs} ms of inactivity (${destroyResponseBodyOnTimeout ? "service default socket timeout" : "configured by client requestHandler"}).`), { name: "TimeoutError" });
|
|
141
|
+
if (destroyResponseBodyOnTimeout) {
|
|
142
|
+
response?.destroy(error);
|
|
143
|
+
}
|
|
131
144
|
request.destroy();
|
|
132
|
-
reject(
|
|
145
|
+
reject(error);
|
|
133
146
|
};
|
|
134
147
|
if (request.socket) {
|
|
135
148
|
request.socket.setTimeout(timeout, onTimeout);
|
|
@@ -143,7 +156,12 @@ const setSocketTimeout = (request, reject, timeoutInMs = 0) => {
|
|
|
143
156
|
registerTimeout(0);
|
|
144
157
|
return 0;
|
|
145
158
|
}
|
|
146
|
-
|
|
159
|
+
const deferralId = timing.setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
|
|
160
|
+
if (destroyResponseBodyOnTimeout) {
|
|
161
|
+
request.once("close", () => timing.clearTimeout(deferralId));
|
|
162
|
+
return 0;
|
|
163
|
+
}
|
|
164
|
+
return deferralId;
|
|
147
165
|
};
|
|
148
166
|
|
|
149
167
|
const MIN_WAIT_TIME = 6_000;
|
|
@@ -383,7 +401,13 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
383
401
|
const effectiveRequestTimeout = requestTimeout ?? config.requestTimeout;
|
|
384
402
|
connectionTimeoutId = setConnectionTimeout(req, reject, config.connectionTimeout);
|
|
385
403
|
requestTimeoutId = setRequestTimeout(req, reject, effectiveRequestTimeout, config.throwOnRequestTimeout, logger ?? console);
|
|
386
|
-
|
|
404
|
+
const defaultSocketTimeout = config.socketTimeout === undefined ? resolveDefaultSocketTimeout(config) : undefined;
|
|
405
|
+
if (defaultSocketTimeout) {
|
|
406
|
+
socketTimeoutId = setSocketTimeout(req, reject, defaultSocketTimeout, true);
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
socketTimeoutId = setSocketTimeout(req, reject, config.socketTimeout);
|
|
410
|
+
}
|
|
387
411
|
const httpAgent = nodeHttpsOptions.agent;
|
|
388
412
|
if (typeof httpAgent === "object" && "keepAlive" in httpAgent) {
|
|
389
413
|
keepAliveTimeoutId = setSocketKeepAlive(req, {
|
|
@@ -423,6 +447,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
423
447
|
connectionTimeout,
|
|
424
448
|
requestTimeout,
|
|
425
449
|
socketTimeout,
|
|
450
|
+
defaultSocketTimeout: resolveDefaultSocketTimeout(options),
|
|
426
451
|
socketAcquisitionWarningTimeout,
|
|
427
452
|
throwOnRequestTimeout,
|
|
428
453
|
httpAgentProvider: async () => {
|
|
@@ -710,7 +735,8 @@ class NodeHttp2Handler {
|
|
|
710
735
|
}
|
|
711
736
|
async handle(request, { abortSignal, requestTimeout, isEventStream } = {}) {
|
|
712
737
|
if (!this.config) {
|
|
713
|
-
|
|
738
|
+
const config = await this.configProvider;
|
|
739
|
+
this.config = { ...config, defaultSocketTimeout: resolveDefaultSocketTimeout(config) };
|
|
714
740
|
const { disableConcurrentStreams, maxConcurrentStreams, nodeHttp2ConnectOptions } = this.config;
|
|
715
741
|
this.connectionManager.setDisableConcurrentStreams(disableConcurrentStreams ?? false);
|
|
716
742
|
if (maxConcurrentStreams) {
|
|
@@ -720,9 +746,12 @@ class NodeHttp2Handler {
|
|
|
720
746
|
this.connectionManager.setNodeHttp2ConnectOptions(nodeHttp2ConnectOptions);
|
|
721
747
|
}
|
|
722
748
|
}
|
|
723
|
-
const { requestTimeout: configRequestTimeout, disableConcurrentStreams } = this.config;
|
|
749
|
+
const { requestTimeout: configRequestTimeout, disableConcurrentStreams, sessionTimeout } = this.config;
|
|
724
750
|
const useIsolatedSession = disableConcurrentStreams || isEventStream;
|
|
725
751
|
const effectiveRequestTimeout = requestTimeout ?? configRequestTimeout;
|
|
752
|
+
const defaultSocketTimeout = effectiveRequestTimeout === undefined && sessionTimeout === undefined
|
|
753
|
+
? this.config.defaultSocketTimeout
|
|
754
|
+
: undefined;
|
|
726
755
|
return new Promise((_resolve, _reject) => {
|
|
727
756
|
let fulfilled = false;
|
|
728
757
|
let writeRequestBodyPromise = undefined;
|
|
@@ -785,6 +814,19 @@ class NodeHttp2Handler {
|
|
|
785
814
|
rejectWithDestroy(timeoutError);
|
|
786
815
|
});
|
|
787
816
|
}
|
|
817
|
+
else if (defaultSocketTimeout) {
|
|
818
|
+
clientHttp2Stream.setTimeout(defaultSocketTimeout, () => {
|
|
819
|
+
const timeoutError = new Error(`Stream timed out because of no activity for ${defaultSocketTimeout} ms`);
|
|
820
|
+
timeoutError.name = "TimeoutError";
|
|
821
|
+
fulfilled = true;
|
|
822
|
+
reject(timeoutError);
|
|
823
|
+
clientHttp2Stream.destroy(timeoutError);
|
|
824
|
+
if (useIsolatedSession) {
|
|
825
|
+
ref.destroy();
|
|
826
|
+
}
|
|
827
|
+
});
|
|
828
|
+
clientHttp2Stream.once("response", () => clientHttp2Stream.setTimeout(defaultSocketTimeout));
|
|
829
|
+
}
|
|
788
830
|
if (abortSignal) {
|
|
789
831
|
const onAbort = () => {
|
|
790
832
|
clientHttp2Stream.close();
|
|
@@ -7,6 +7,7 @@ import { node_https } from "./node-https";
|
|
|
7
7
|
import { setConnectionTimeout } from "./set-connection-timeout";
|
|
8
8
|
import { setRequestTimeout } from "./set-request-timeout";
|
|
9
9
|
import { setSocketKeepAlive } from "./set-socket-keep-alive";
|
|
10
|
+
import { resolveDefaultSocketTimeout } from "./resolve-default-socket-timeout";
|
|
10
11
|
import { setSocketTimeout } from "./set-socket-timeout";
|
|
11
12
|
import { timing } from "./timing";
|
|
12
13
|
import { writeRequestBody } from "./write-request-body";
|
|
@@ -185,7 +186,13 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
185
186
|
const effectiveRequestTimeout = requestTimeout ?? config.requestTimeout;
|
|
186
187
|
connectionTimeoutId = setConnectionTimeout(req, reject, config.connectionTimeout);
|
|
187
188
|
requestTimeoutId = setRequestTimeout(req, reject, effectiveRequestTimeout, config.throwOnRequestTimeout, logger ?? console);
|
|
188
|
-
|
|
189
|
+
const defaultSocketTimeout = config.socketTimeout === undefined ? resolveDefaultSocketTimeout(config) : undefined;
|
|
190
|
+
if (defaultSocketTimeout) {
|
|
191
|
+
socketTimeoutId = setSocketTimeout(req, reject, defaultSocketTimeout, true);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
socketTimeoutId = setSocketTimeout(req, reject, config.socketTimeout);
|
|
195
|
+
}
|
|
189
196
|
const httpAgent = nodeHttpsOptions.agent;
|
|
190
197
|
if (typeof httpAgent === "object" && "keepAlive" in httpAgent) {
|
|
191
198
|
keepAliveTimeoutId = setSocketKeepAlive(req, {
|
|
@@ -225,6 +232,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
225
232
|
connectionTimeout,
|
|
226
233
|
requestTimeout,
|
|
227
234
|
socketTimeout,
|
|
235
|
+
defaultSocketTimeout: resolveDefaultSocketTimeout(options),
|
|
228
236
|
socketAcquisitionWarningTimeout,
|
|
229
237
|
throwOnRequestTimeout,
|
|
230
238
|
httpAgentProvider: async () => {
|
|
@@ -3,6 +3,7 @@ import { buildAbortError } from "./build-abort-error";
|
|
|
3
3
|
import { getTransformedHeaders } from "./get-transformed-headers";
|
|
4
4
|
import { node_http2 } from "./node-http2";
|
|
5
5
|
import { NodeHttp2ConnectionManager } from "./node-http2-connection-manager";
|
|
6
|
+
import { resolveDefaultSocketTimeout } from "./resolve-default-socket-timeout";
|
|
6
7
|
import { writeRequestBody } from "./write-request-body";
|
|
7
8
|
const { constants } = node_http2;
|
|
8
9
|
export class NodeHttp2Handler {
|
|
@@ -35,7 +36,8 @@ export class NodeHttp2Handler {
|
|
|
35
36
|
}
|
|
36
37
|
async handle(request, { abortSignal, requestTimeout, isEventStream } = {}) {
|
|
37
38
|
if (!this.config) {
|
|
38
|
-
|
|
39
|
+
const config = await this.configProvider;
|
|
40
|
+
this.config = { ...config, defaultSocketTimeout: resolveDefaultSocketTimeout(config) };
|
|
39
41
|
const { disableConcurrentStreams, maxConcurrentStreams, nodeHttp2ConnectOptions } = this.config;
|
|
40
42
|
this.connectionManager.setDisableConcurrentStreams(disableConcurrentStreams ?? false);
|
|
41
43
|
if (maxConcurrentStreams) {
|
|
@@ -45,9 +47,12 @@ export class NodeHttp2Handler {
|
|
|
45
47
|
this.connectionManager.setNodeHttp2ConnectOptions(nodeHttp2ConnectOptions);
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
|
-
const { requestTimeout: configRequestTimeout, disableConcurrentStreams } = this.config;
|
|
50
|
+
const { requestTimeout: configRequestTimeout, disableConcurrentStreams, sessionTimeout } = this.config;
|
|
49
51
|
const useIsolatedSession = disableConcurrentStreams || isEventStream;
|
|
50
52
|
const effectiveRequestTimeout = requestTimeout ?? configRequestTimeout;
|
|
53
|
+
const defaultSocketTimeout = effectiveRequestTimeout === undefined && sessionTimeout === undefined
|
|
54
|
+
? this.config.defaultSocketTimeout
|
|
55
|
+
: undefined;
|
|
51
56
|
return new Promise((_resolve, _reject) => {
|
|
52
57
|
let fulfilled = false;
|
|
53
58
|
let writeRequestBodyPromise = undefined;
|
|
@@ -110,6 +115,19 @@ export class NodeHttp2Handler {
|
|
|
110
115
|
rejectWithDestroy(timeoutError);
|
|
111
116
|
});
|
|
112
117
|
}
|
|
118
|
+
else if (defaultSocketTimeout) {
|
|
119
|
+
clientHttp2Stream.setTimeout(defaultSocketTimeout, () => {
|
|
120
|
+
const timeoutError = new Error(`Stream timed out because of no activity for ${defaultSocketTimeout} ms`);
|
|
121
|
+
timeoutError.name = "TimeoutError";
|
|
122
|
+
fulfilled = true;
|
|
123
|
+
reject(timeoutError);
|
|
124
|
+
clientHttp2Stream.destroy(timeoutError);
|
|
125
|
+
if (useIsolatedSession) {
|
|
126
|
+
ref.destroy();
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
clientHttp2Stream.once("response", () => clientHttp2Stream.setTimeout(defaultSocketTimeout));
|
|
130
|
+
}
|
|
113
131
|
if (abortSignal) {
|
|
114
132
|
const onAbort = () => {
|
|
115
133
|
clientHttp2Stream.close();
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { timing } from "./timing";
|
|
2
2
|
const DEFER_EVENT_LISTENER_TIME = 3000;
|
|
3
|
-
export const setSocketTimeout = (request, reject, timeoutInMs = 0) => {
|
|
3
|
+
export const setSocketTimeout = (request, reject, timeoutInMs = 0, destroyResponseBodyOnTimeout = false) => {
|
|
4
|
+
let response;
|
|
5
|
+
if (destroyResponseBodyOnTimeout) {
|
|
6
|
+
request.once("response", (res) => (response = res));
|
|
7
|
+
}
|
|
4
8
|
const registerTimeout = (offset) => {
|
|
5
9
|
const timeout = timeoutInMs - offset;
|
|
6
10
|
const onTimeout = () => {
|
|
11
|
+
const error = Object.assign(new Error(`@smithy/node-http-handler - the request socket timed out after ${timeoutInMs} ms of inactivity (${destroyResponseBodyOnTimeout ? "service default socket timeout" : "configured by client requestHandler"}).`), { name: "TimeoutError" });
|
|
12
|
+
if (destroyResponseBodyOnTimeout) {
|
|
13
|
+
response?.destroy(error);
|
|
14
|
+
}
|
|
7
15
|
request.destroy();
|
|
8
|
-
reject(
|
|
16
|
+
reject(error);
|
|
9
17
|
};
|
|
10
18
|
if (request.socket) {
|
|
11
19
|
request.socket.setTimeout(timeout, onTimeout);
|
|
@@ -19,5 +27,10 @@ export const setSocketTimeout = (request, reject, timeoutInMs = 0) => {
|
|
|
19
27
|
registerTimeout(0);
|
|
20
28
|
return 0;
|
|
21
29
|
}
|
|
22
|
-
|
|
30
|
+
const deferralId = timing.setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
|
|
31
|
+
if (destroyResponseBodyOnTimeout) {
|
|
32
|
+
request.once("close", () => timing.clearTimeout(deferralId));
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
return deferralId;
|
|
23
36
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/node-http-handler",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.13.0",
|
|
4
4
|
"description": "Provides a way to make requests",
|
|
5
5
|
"homepage": "https://github.com/smithy-lang/smithy-typescript/tree/main/packages/node-http-handler",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@smithy/core": "^3.
|
|
33
|
-
"@smithy/types": "^4.
|
|
32
|
+
"@smithy/core": "^3.37.0",
|
|
33
|
+
"@smithy/types": "^4.19.0",
|
|
34
34
|
"tslib": "^2.6.2"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|