The Wayback Machine - http://web.archive.org/web/20201016120745/https://github.com/aws-amplify/amplify-js/issues/6069
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

Sign in event gets registered multiple times when using regular Auth.signIn() #6069

Open
ooridoori opened this issue Jun 12, 2020 · 4 comments
Open

Comments

@ooridoori
Copy link

@ooridoori ooridoori commented Jun 12, 2020

Describe the bug
When a user signs in using Auth.signIn() the "signIn" event is registered multiple times in the Hub listener

To Reproduce

  1. Add a log inside the "signIn" event in the Hub.listener callback
  2. Open devtools
  3. Sign in using Auth.signIn()
  4. Notice there is at least 4 or more logs and the same amount of network calls

Expected behavior
The sign in event should only happen once - im bypassing this by keeping track of page loads. :\

Code Snippet

Hub.listen('auth', ({ payload: { event, data } }) => {
    switch (event) {
      case 'signIn':
         console.log('heard sign in event! ')
//...rest of code

Screenshots
Screen Shot 2020-06-11 at 6 14 01 PM
Screen Shot 2020-06-11 at 6 22 42 PM

@danluszcz-pariveda
Copy link

@danluszcz-pariveda danluszcz-pariveda commented Jun 15, 2020

I'm seeing a possibly related issue, our Cognito Pre Token Generation lambda function was triggered 82 times in less than a second for the same user.

@ehtulhaq
Copy link

@ehtulhaq ehtulhaq commented Jun 23, 2020

I see this issue too..specially on android when using social federated sign up

@ehtulhaq
Copy link

@ehtulhaq ehtulhaq commented Jul 1, 2020

Since i had business logic that was being called many times my workaround was to move the business logic out from Hub.listen and add another middle layer where my business logic gets executed. Sign in event in Hub.listen would redirect the user to the middle layer where my business logic gets executed and which then redirects to the appropriate screen.

@kendevops kendevops added this to In Progress ✍️ in Fellowship Contribution Board Jul 8, 2020
@mauerbac mauerbac removed this from In Progress ✍️ in Fellowship Contribution Board Aug 12, 2020
@sammartinez sammartinez added the Hub label Sep 16, 2020
@nqbao
Copy link

@nqbao nqbao commented Oct 7, 2020

I also have the same problem. The sign event is called multiple time when login

Screen Shot 2020-10-07 at 3 13 25 PM

The code is quite simple

    Hub.listen("auth", ({ payload: { event, data } }) => {
      console.log('event', event)
      switch (event) {
        case "signIn":
          // console.log(123)
          this.setState({ user: data });
          break;
        case "signOut":
          this.setState({ user: null });
          break;
        case "customOAuthState":
          this.setState({ customState: data });
      }
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
You can’t perform that action at this time.