aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
2.97k stars 556 forks source link

client-transcribe-streaming StartStreamTranscriptionCommand got ERR_HTTP2_HEADER_SINGLE_VALUE error #6254

Open MirandaDora opened 3 days ago

MirandaDora commented 3 days ago

Checkboxes for prior research

Describe the bug

Hi, I have copy pasted the streaming code from https://docs.aws.amazon.com/transcribe/latest/dg/getting-started-sdk.html And when executing the code, I've got the following error:

An error was encountered in a non-retryable streaming request.
node:internal/http2/util:633
        throw new ERR_HTTP2_HEADER_SINGLE_VALUE(key);
              ^

TypeError [ERR_HTTP2_HEADER_SINGLE_VALUE]: Header field "content-type" must only have a single value
    at mapToHeaders (node:internal/http2/util:633:15)
    at ClientHttp2Session.request (node:internal/http2/core:1813:25)
    at /Users/miranli/Projects/jam/simultaneous-interpretation-jam/node_modules/@smithy/node-http-handler/dist-cjs/index.js:588:27
    at new Promise (<anonymous>)
    at _NodeHttp2Handler.handle (/Users/miranli/Projects/jam/simultaneous-interpretation-jam/node_modules/@smithy/node-http-handler/dist-cjs/index.js:541:12)
    at async /Users/miranli/Projects/jam/simultaneous-interpretation-jam/node_modules/@smithy/middleware-serde/dist-cjs/index.js:33:24
    at async _EventStreamPayloadHandler.handle (/Users/miranli/Projects/jam/simultaneous-interpretation-jam/node_modules/@aws-sdk/eventstream-handler-node/dist-cjs/index.js:110:16) {
  code: 'ERR_HTTP2_HEADER_SINGLE_VALUE'
}

Node.js v20.15.0

I have tried to execute the batch code, it's working. Only this one got issue. "@aws-sdk/client-transcribe": "^3.609.0", "@aws-sdk/client-transcribe-streaming": "^3.609.0",

SDK version number

@aws-sdk/package-name@version, ...

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

Node.js v20.15.0

Reproduction Steps

Create a clean nodejs project, put the code from "streaming" section for javascript in this document: https://docs.aws.amazon.com/transcribe/latest/dg/getting-started-sdk.html And execute

Observed Behavior

As described

Expected Behavior

It should start to stream the audio file

Possible Solution

No response

Additional Information/Context

No response

haochunchang commented 2 days ago

I have encountered the same issue yesterday. For my use case, I commented out the following line (in dist-cjs/index.js) and my request starts working:

https://github.com/aws/aws-sdk-js-v3/blob/0b87b64a0290d3aaa4dd9753eab8be66c2598c97/clients/client-transcribe-streaming/src/protocols/Aws_restJson1.ts#L147

Hopefully this workaround can help.

Another clue is that the request headers, I found out it already has: 'Content-Type': 'application/vnd.amazon.eventstream’ which might comes from here: https://github.com/aws/aws-sdk-js-v3/blob/0b87b64a0290d3aaa4dd9753eab8be66c2598c97/packages/middleware-eventstream/src/eventStreamHeaderMiddleware.ts#L8 But I do not know how to fix this yet.

MirandaDora commented 2 days ago

Hi @haochunchang -- thanks sooo much for this. Your workaround is working for me. However, I would still prefer to get this fixed as this is in node_modules and ideally we won't need to change code in the library itself. Let's keep this one open and make sure it catches AWS folks' eyes.

Again, thanks heaps!!

aBurmeseDev commented 1 day ago

HI @MirandaDora - thanks for reaching out and apology for the inconvenience.

I was able to reproduce the reported behavior and also confirm the workaround mentioned by @haochunchang . I'll bring it up to the team to further discuss and investigate the issue.