Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(credential-providers): avoid sharing http2 requestHandler with inner STS #6389

Merged
merged 1 commit into from
Aug 15, 2024

Conversation

kuhe
Copy link
Contributor

@kuhe kuhe commented Aug 15, 2024

Issue

#5958

Description

Avoid sharing the parent client requestHandler to the inner STS client if that handler is an HTTP2 handler.
All other types of known handlers: fetch, http1.1, websocket (because it defers to fetch for non-ws), xhr, are valid for STS.

Testing

Made a TranscribeStreaming (HTTP2 default requesthandler) request and used the default provider chain such that it involved an STS credentials request.

Verified this PR makes the difference in that not working -> working.

Sample code:

import { TranscribeStreaming } from "@aws-sdk/client-transcribe-streaming";
import { fromIni } from "@aws-sdk/credential-providers";
import { createReadStream } from "node:fs";
import { join } from "node:path";

const audio = createReadStream(join("numbers.wav"));

process.env.AWS_PROFILE = "sts";

/**
 * When no credentials or requestHandler are specified, the http2
 * request handler default on the client is shared with the
 * inner STS client via config copying, but is invalid
 * for STS, which needs a regular http1 requestHandler.
 */

const ts = new TranscribeStreaming({
  region: "us-west-2",
  logger: console,
});

const LanguageCode = "en-GB";
const MediaEncoding = "pcm";
const MediaSampleRateHertz = 44100;
const result = await ts.startStreamTranscription({
  LanguageCode,
  MediaEncoding,
  MediaSampleRateHertz,
  AudioStream: (async function* () {
    for await (const chunk of audio) {
      yield { AudioEvent: { AudioChunk: chunk } };
    }
  })(),
});
const transcripts = [];
for await (const event of result.TranscriptResultStream) {
  transcripts.push(event);
}
console.log(transcripts);

@kuhe kuhe requested a review from a team as a code owner August 15, 2024 16:40
@kuhe
Copy link
Contributor Author

kuhe commented Aug 15, 2024

npx cucumber-js -t @sts
...........

@kuhe kuhe merged commit d7b1610 into aws:main Aug 15, 2024
5 checks passed
@kuhe kuhe deleted the fix/sts branch August 15, 2024 17:22
Copy link

github-actions bot commented Sep 2, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants