aws-samples / aws-sdk-js-notes-app

A simple note taking application using modular AWS SDK for JavaScript (v3)
Other
81 stars 30 forks source link

"Error: Expected SignatureV4 signer" when trying to use real-time audio transcription on production bundle #20

Closed trivikr closed 3 years ago

trivikr commented 3 years ago

Describe the bug

The following error is thrown on trying real-time audio transcription on production bundle of the frontend:

Error: Expected SignatureV4 signer, please check the client constructor.

Steps to reproduce

Follow setup https://github.com/aws-samples/aws-sdk-js-notes-app#setup

Observed behavior

The following error is thrown:

Error: Expected SignatureV4 signer, please check the client constructor.

Expected behavior

Error shouldn't be thrown, and Transcribe Streaming Transcription should work as shown in the video recording below:

Recording [![Screen recording](https://img.youtube.com/vi/fF9zd0YJn6A/0.jpg)](https://www.youtube.com/watch?v=fF9zd0YJn6A)

Screenshots

Screenshot ![Screen Shot 2021-02-05 at 9 53 05 AM](https://user-images.githubusercontent.com/16024985/107070542-585b4b00-6798-11eb-83a5-7fad32d4c864.png)

Additional context

The error is not thrown on Development bundle, i.e. one created using yarn start:frontend

trivikr commented 3 years ago

The line from the SDK v3 which throws error: https://github.com/aws/aws-sdk-js-v3/blob/d2e8d4f4d53166416e86d12a1a953e31368f55ac/packages/middleware-sdk-transcribe-streaming/src/configuration.ts#L30

davidpene commented 3 years ago

Hey @trivikr any updates on this?

markbrouch commented 3 years ago

I am also experiencing this bug. The culprit is on this line: https://github.com/aws/aws-sdk-js-v3/blob/d2e8d4f4d53166416e86d12a1a953e31368f55ac/packages/middleware-sdk-transcribe-streaming/src/configuration.ts#L37

What is happening is that production build tools are minifying files, causing the SignatureV4 class to be renamed to something like _a. By doing this hacky .indexOf("SignatureV4") lookup in validateSigner, this package is broken for any system that minifies code (common client-side production practice). This SDK will not work in production environments with code minification turned on until this is remediated.

trivikr commented 3 years ago

Verified that this issue is fixed after bumping @aws-sdk/* packages to v3.27.0 in https://github.com/aws-samples/aws-sdk-js-notes-app/pull/49