On which framework/platform are you having an issue?
React
Which UI component?
Authenticator
How is your app built?
Vite
What browsers are you seeing the problem on?
Chrome, Firefox, Microsoft Edge, Safari
Which region are you seeing the problem in?
us-east-1
Please describe your bug.
At the entry point of my app, I am performing a fetch call to get configuration values, then manually performing Amplify.configure. After the fetch call I am creating the root and loading the Authenticator component. This is creating a race condition which can be solved by awaiting the fetch call before creating the root or by adding the createRoot in the then after the fetch call.
However, without the fix, the authenticator loads before amplify is configured. Then when you attempt to login, behind the scenes the authenticator checks if a user is logged in (Which there is) and it returns the error There is already a signed in user. and doesnt reload the component. This cause the site to be stuck at the authenticator and there is no way to get around it. Reloading will load the whole app recreating the problem.
I have two potential suggestions for handling this use case.
Reloading the authenticator component once the first time amplify.configure is called. This needs to be thought through because there could be potential security concerns around this.
When handling that specific error, reload the component. That error is indicative that there we are succesfully connecting to cognito and that someone is currently signed in according to the session and auth data, which should just bypass the authenticator anyway.
What's the expected behaviour?
I would expect when I click sign in, that if there is already a user signed in, it would load the application
Help us reproduce the bug!
In order to reproduce, create a race condition between when you configure amplify and when you load the authenticator. You can use the example code below. You can also just do create a short timeout before doing your normal amplify configure which should reproduce the same results.
Before creating a new issue, please confirm:
On which framework/platform are you having an issue?
React
Which UI component?
Authenticator
How is your app built?
Vite
What browsers are you seeing the problem on?
Chrome, Firefox, Microsoft Edge, Safari
Which region are you seeing the problem in?
us-east-1
Please describe your bug.
At the entry point of my app, I am performing a fetch call to get configuration values, then manually performing
Amplify.configure
. After the fetch call I am creating the root and loading the Authenticator component. This is creating a race condition which can be solved by awaiting the fetch call before creating the root or by adding the createRoot in thethen
after the fetch call.However, without the fix, the authenticator loads before amplify is configured. Then when you attempt to login, behind the scenes the authenticator checks if a user is logged in (Which there is) and it returns the error
There is already a signed in user.
and doesnt reload the component. This cause the site to be stuck at the authenticator and there is no way to get around it. Reloading will load the whole app recreating the problem.I have two potential suggestions for handling this use case.
What's the expected behaviour?
I would expect when I click sign in, that if there is already a user signed in, it would load the application
Help us reproduce the bug!
In order to reproduce, create a race condition between when you configure amplify and when you load the authenticator. You can use the example code below. You can also just do create a short timeout before doing your normal amplify configure which should reproduce the same results.
Code Snippet
In
main.jsx
In
App.jsx
Console log output
No response
Additional information and screenshots