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: override default CognitoIdentityClient config to remove assumption of fetch body support #5707

Closed

Conversation

russell-dot-js
Copy link

Issue #, if available: #5332, #5534

Description of changes: Update CognitoIdentityClient to use the native fetch configuration, as this does not expect the environment to implement response.body as a ReadableStream, and is safe to use in any browser that has native fetch or polyfill.

This is a temporary fix. The real issue is in the @aws-sdk-js-v3 repo, and a number of things are currently being discussed and reviewed:
aws/aws-sdk-js-v3#1107
aws/aws-sdk-js-v3#1121
aws/aws-sdk-js-v3#1123

I put up this PR as a short-term fix as this is impacting myself, as well as @Stereobits, and unknown others, in production. Please note that this only fixes the usage of CognitoIdentityClient. There are other clients used in the analytics, interactions, predictions, and storage packages that are not fixed by this PR (but those will be fixed via either of the SDK PR's).

I have not tested this yet. Sorry for pushing up this PR without testing, but I have to run right now and wanted to get eyes on it preliminary. Any insight in to how the amplify packages are usually tested would be greatly appreciated.

Question: I updated dependencies, but no changes were made to yarn.lock, so I looked and could not find a yarn.lock in the repository, but I found a couple one-off package-lock.json's. Is this repo not using a lockfile?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@russell-dot-js
Copy link
Author

@Stereobit hopefully this will help you.

Other solution is to use this package along with whatwg-fetch: https://www.npmjs.com/package/@stardazed/streams-polyfill

However, in my testing, the streams-polyfill breaks the amplify amazon-cognito-identity-js package, somehow causing the fetch response to be attempted to be read twice. I was only able to get it working by only using the streams-polyfill for logged-in users (when CognitoIdentityClient is used before making API requests), and avoiding the polyfill when logged out so that amazon-cognito-identity-js could do its thing. Overall it was very flakey and I was not comfortable going down that route.

@russell-dot-js
Copy link
Author

Also pinging @Amplifiyer

@russell-dot-js russell-dot-js force-pushed the short-term-cognito-fix branch from 51960a7 to 21fde63 Compare May 6, 2020 20:05
@codecov
Copy link

codecov bot commented May 6, 2020

Codecov Report

Merging #5707 into master will increase coverage by 0.01%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5707      +/-   ##
==========================================
+ Coverage   73.61%   73.62%   +0.01%     
==========================================
  Files         204      204              
  Lines       11882    11884       +2     
  Branches     2237     2236       -1     
==========================================
+ Hits         8747     8750       +3     
+ Misses       2973     2972       -1     
  Partials      162      162              
Impacted Files Coverage Δ
packages/core/src/Credentials.ts 32.56% <33.33%> (+1.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1a3cd7c...21fde63. Read the comment docs.

@amhinson amhinson changed the base branch from master to main June 18, 2020 18:49
@amhinson amhinson requested a review from elorzafe August 20, 2020 16:15
@sammartinez
Copy link
Contributor

Closing this PR as the above issues listed with AWS SDK JavaScript package have been resolved.

@github-actions
Copy link

This pull request has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 20, 2021
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