Skip to content

Commit dd7f5fe

Browse files
committed
fix(clients): re-enable default http2 session concurrency
1 parent 5873496 commit dd7f5fe

11 files changed

Lines changed: 93 additions & 37 deletions

File tree

clients/client-bedrock-runtime/src/runtimeConfig.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ export const getRuntimeConfig = (config: BedrockRuntimeClientConfig) => {
8080
NODE_REGION_CONFIG_OPTIONS,
8181
{...NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig}
8282
),
83-
requestHandler: RequestHandler.create(config?.requestHandler ?? (async () => ({
84-
...await defaultConfigProvider(),
85-
disableConcurrentStreams: true
86-
}))),
83+
requestHandler: RequestHandler.create(config?.requestHandler ?? defaultConfigProvider),
8784
retryMode:
8885
config?.retryMode ??
8986
loadNodeConfig(

clients/client-bedrock-runtime/test/BedrockRuntime.e2e.spec.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { ListAsyncInvokesCommandOutput } from "@aws-sdk/client-bedrock-runtime";
12
import { BedrockRuntime } from "@aws-sdk/client-bedrock-runtime";
23
import { SignatureV4 } from "@smithy/signature-v4";
34
import { toBase64 } from "@smithy/util-base64";
@@ -8,6 +9,9 @@ describe("BedrockRuntime", () => {
89
const client = new BedrockRuntime({
910
region: "us-west-2",
1011
credentials: aws?.testCredentials,
12+
requestHandler: {
13+
maxConcurrentStreams: 3,
14+
},
1115
});
1216

1317
let signerCredentialProviderSpy: any;
@@ -69,6 +73,7 @@ describe("BedrockRuntime", () => {
6973
const inputEnd = new Promise((r) => {
7074
resolve = r;
7175
});
76+
const listAsyncInvokesOutputs: ListAsyncInvokesCommandOutput[] = [];
7277

7378
const response = await client.invokeModelWithBidirectionalStream({
7479
modelId,
@@ -178,6 +183,15 @@ describe("BedrockRuntime", () => {
178183
},
179184
};
180185

186+
// At midpoint, fire parallel requests over the same client
187+
// to verify HTTP/2 session concurrency doesn't interfere with the ongoing stream.
188+
if (it === 10) {
189+
const results = await Promise.all(
190+
Array.from({ length: 8 }, () => client.listAsyncInvokes({ maxResults: 1 }))
191+
);
192+
listAsyncInvokesOutputs.push(...results);
193+
}
194+
181195
if (it % 15 === 3) {
182196
yields.push("contentEnd");
183197
yield {
@@ -266,6 +280,40 @@ describe("BedrockRuntime", () => {
266280
"sessionEnd",
267281
]);
268282

283+
// Verify parallel requests completed successfully during the bidirectional stream.
284+
expect(listAsyncInvokesOutputs).toHaveLength(8);
285+
for (const result of listAsyncInvokesOutputs) {
286+
expect(result.$metadata.httpStatusCode).toBe(200);
287+
}
288+
289+
const h2SessionState = (client.config.requestHandler as any).connectionManager?.debug?.();
290+
if (h2SessionState) {
291+
expect(h2SessionState).toMatchObject({
292+
"https://bedrock-runtime.us-west-2.amazonaws.com/": {
293+
sessions: [
294+
{
295+
active: expect.any(Number),
296+
id: expect.any(Number),
297+
maxConcurrent: 3,
298+
totalRequests: 3,
299+
},
300+
{
301+
active: expect.any(Number),
302+
id: expect.any(Number),
303+
maxConcurrent: 3,
304+
totalRequests: 3,
305+
},
306+
{
307+
active: expect.any(Number),
308+
id: expect.any(Number),
309+
maxConcurrent: 2,
310+
totalRequests: 2,
311+
},
312+
],
313+
},
314+
});
315+
}
316+
269317
// There are no other response fields currently.
270318
// Therefore, there is no difference in assertions for WebSocket and HTTP2.
271319
expect(response.body).toBeDefined();

clients/client-connecthealth/src/runtimeConfig.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ export const getRuntimeConfig = (config: ConnectHealthClientConfig) => {
5555
NODE_REGION_CONFIG_OPTIONS,
5656
{...NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig}
5757
),
58-
requestHandler: RequestHandler.create(config?.requestHandler ?? (async () => ({
59-
...await defaultConfigProvider(),
60-
disableConcurrentStreams: true
61-
}))),
58+
requestHandler: RequestHandler.create(config?.requestHandler ?? defaultConfigProvider),
6259
retryMode:
6360
config?.retryMode ??
6461
loadNodeConfig(

clients/client-kinesis/src/runtimeConfig.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ export const getRuntimeConfig = (config: KinesisClientConfig) => {
5353
NODE_REGION_CONFIG_OPTIONS,
5454
{...NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig}
5555
),
56-
requestHandler: RequestHandler.create(config?.requestHandler ?? (async () => ({
57-
...await defaultConfigProvider(),
58-
disableConcurrentStreams: true
59-
}))),
56+
requestHandler: RequestHandler.create(config?.requestHandler ?? defaultConfigProvider),
6057
retryMode:
6158
config?.retryMode ??
6259
loadNodeConfig(

clients/client-lex-runtime-v2/src/runtimeConfig.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ export const getRuntimeConfig = (config: LexRuntimeV2ClientConfig) => {
5555
NODE_REGION_CONFIG_OPTIONS,
5656
{...NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig}
5757
),
58-
requestHandler: RequestHandler.create(config?.requestHandler ?? (async () => ({
59-
...await defaultConfigProvider(),
60-
disableConcurrentStreams: true
61-
}))),
58+
requestHandler: RequestHandler.create(config?.requestHandler ?? defaultConfigProvider),
6259
retryMode:
6360
config?.retryMode ??
6461
loadNodeConfig(

clients/client-polly/src/runtimeConfig.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ export const getRuntimeConfig = (config: PollyClientConfig) => {
5555
NODE_REGION_CONFIG_OPTIONS,
5656
{...NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig}
5757
),
58-
requestHandler: RequestHandler.create(config?.requestHandler ?? (async () => ({
59-
...await defaultConfigProvider(),
60-
disableConcurrentStreams: true
61-
}))),
58+
requestHandler: RequestHandler.create(config?.requestHandler ?? defaultConfigProvider),
6259
retryMode:
6360
config?.retryMode ??
6461
loadNodeConfig(

clients/client-qbusiness/src/runtimeConfig.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ export const getRuntimeConfig = (config: QBusinessClientConfig) => {
5555
NODE_REGION_CONFIG_OPTIONS,
5656
{...NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig}
5757
),
58-
requestHandler: RequestHandler.create(config?.requestHandler ?? (async () => ({
59-
...await defaultConfigProvider(),
60-
disableConcurrentStreams: true
61-
}))),
58+
requestHandler: RequestHandler.create(config?.requestHandler ?? defaultConfigProvider),
6259
retryMode:
6360
config?.retryMode ??
6461
loadNodeConfig(

clients/client-sagemaker-runtime-http2/src/runtimeConfig.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ export const getRuntimeConfig = (config: SageMakerRuntimeHTTP2ClientConfig) => {
5555
NODE_REGION_CONFIG_OPTIONS,
5656
{...NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig}
5757
),
58-
requestHandler: RequestHandler.create(config?.requestHandler ?? (async () => ({
59-
...await defaultConfigProvider(),
60-
disableConcurrentStreams: true
61-
}))),
58+
requestHandler: RequestHandler.create(config?.requestHandler ?? defaultConfigProvider),
6259
retryMode:
6360
config?.retryMode ??
6461
loadNodeConfig(

clients/client-transcribe-streaming/src/runtimeConfig.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ export const getRuntimeConfig = (config: TranscribeStreamingClientConfig) => {
5555
NODE_REGION_CONFIG_OPTIONS,
5656
{...NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig}
5757
),
58-
requestHandler: RequestHandler.create(config?.requestHandler ?? (async () => ({
59-
...await defaultConfigProvider(),
60-
disableConcurrentStreams: true
61-
}))),
58+
requestHandler: RequestHandler.create(config?.requestHandler ?? defaultConfigProvider),
6259
retryMode:
6360
config?.retryMode ??
6461
loadNodeConfig(

clients/client-transcribe-streaming/test/TranscribeStreaming.e2e.spec.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,49 @@ describe("TranscribeStream client", { retry: 4 }, () => {
5353

5454
expect(result.TranscriptResultStream).toBeDefined();
5555
const transcripts: any[] = [];
56+
let parallelRequestsDone = false;
5657
for await (const event of result.TranscriptResultStream!) {
5758
transcripts.push(event);
59+
60+
// After receiving the first event, fire parallel read requests over the same client
61+
// to verify HTTP/2 session concurrency doesn't interfere with the ongoing stream.
62+
if (!parallelRequestsDone && transcripts.length === 1 && i === 0) {
63+
parallelRequestsDone = true;
64+
const results = await Promise.allSettled(
65+
Array.from({ length: 3 }, () => client.getMedicalScribeStream({ SessionId: "non-existent-session-id" }))
66+
);
67+
for (const r of results) {
68+
// A rejected request with a service error still proves the HTTP/2 round-trip succeeded
69+
// concurrently with the active stream.
70+
expect(r.status === "rejected" ? r.reason?.name : r.status).toMatch(/InternalFailure/);
71+
}
72+
}
5873
}
5974

6075
expect(transcripts.filter((event) => event["TranscriptEvent"]).length).toBeGreaterThan(0);
6176
})
6277
);
78+
79+
const h2SessionState = (client.config.requestHandler as any).connectionManager?.debug?.();
80+
if (h2SessionState) {
81+
expect(h2SessionState).toMatchObject({
82+
"https://transcribestreaming.us-west-2.amazonaws.com/": {
83+
sessions: [
84+
{
85+
active: expect.any(Number),
86+
id: expect.any(Number),
87+
maxConcurrent: 3,
88+
totalRequests: expect.any(Number),
89+
},
90+
],
91+
},
92+
});
93+
expect(
94+
h2SessionState["https://transcribestreaming.us-west-2.amazonaws.com/"].sessions
95+
.map((s: any) => s.totalRequests)
96+
.reduce((a: number, b: number) => a + b, 0)
97+
).toEqual(45);
98+
}
6399
}
64100
);
65101
});

0 commit comments

Comments
 (0)