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

refactor(auth): clean signIn state after all relevant async works finish #14053

Merged
merged 3 commits into from
Dec 11, 2024

Conversation

zhouzh1
Copy link

@zhouzh1 zhouzh1 commented Dec 4, 2024

Description of changes

  • Moved all the cleanActiveSignInState method invocations to after the cacheCognitoTokens method invocations, so that we can ensure the signIn state is only cleaned when all the tasks which're possible to throw error have been successfully finished, otherwise it would cause the relevant APIs isn't able to be retried on errors (e.g. network error).

Issue #, if available

Description of how you validated changes

Checklist

  • PR description included
  • yarn test passes

Checklist for repo maintainers

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

@zhouzh1
Copy link
Author

zhouzh1 commented Dec 4, 2024

@cshfang @HuiSF @pranavosu Could you help take a look if this PR makes sense?

@jjarvisp
Copy link
Member

jjarvisp commented Dec 4, 2024

Hi @zhouzh1, thanks for the pull request! These changes look reasonable; will review internally with the team and follow up if we need anything else.

@jjarvisp
Copy link
Member

jjarvisp commented Dec 4, 2024

Hey @zhouzh1, are you able to clean up the linting errors so we can get the unit tests running? You should just need to run yarn lint:fix --scope @aws-amplify/auth

@jjarvisp jjarvisp added feature-request Request a new feature Auth Related to Auth components/category external-contributor labels Dec 5, 2024
@jjarvisp jjarvisp requested a review from sktimalsina as a code owner December 6, 2024 18:07
@jjarvisp jjarvisp requested a review from a team as a code owner December 6, 2024 20:42
jjarvisp
jjarvisp previously approved these changes Dec 6, 2024
@jjarvisp jjarvisp self-requested a review December 6, 2024 20:55
@jjarvisp jjarvisp force-pushed the refactor/clean_signIn_state branch from 5e01c74 to 0f06e78 Compare December 6, 2024 21:19
@jjarvisp
Copy link
Member

jjarvisp commented Dec 9, 2024

@zhouzh1
Copy link
Author

zhouzh1 commented Dec 10, 2024

@jjarvisp I tried the yarn lint:fix --scope @aws-amplify/auth command, but seems that all the displayed linting errors aren't related to my change (my change is simple, I guess it wouldn't introduce linting error), they're all relevant with the failed module path resolving.

@zhouzh1
Copy link
Author

zhouzh1 commented Dec 11, 2024

@jjarvisp @HuiSF One more question, I am thinking that is the cleanActiveSignInState invocation in the catch clause necessary? Because it will cause the associated API not able to be retried as well, and also, I saw that there is no such a invocation in the confirmSignIn API's corresponding catch clause, not sure if this kind of inconsistence is intentional or not. Please help confirm that, thanks.
image
image

@jjarvisp
Copy link
Member

Hey @zhouzh1, this is intentional. In the case above, omitting the cleanActiveSignInState with confirmSignIn allows users to manually retry the api without losing context of the current sign in session - for example, submitting an OTP code that may have been entered incorrectly initially. Conversely, during the signIn operation there is no context that needs to be persisted. Each sign in operation should be independent and all required dependencies are available from the input or configuration files.

If you're running into any more challenges, feel free to open an issue and we can discuss there!

@jjarvisp jjarvisp changed the title refactor: clean signIn state after all relevant async works finish refactor(auth): clean signIn state after all relevant async works finish Dec 11, 2024
@jjarvisp jjarvisp merged commit 881619d into aws-amplify:main Dec 11, 2024
59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auth Related to Auth components/category external-contributor feature-request Request a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants