Skip to content
This repository has been archived by the owner on Apr 1, 2019. It is now read-only.

BUG - performLogin called multiple times #35

Open
andrepcg opened this issue Nov 23, 2017 · 1 comment · May be fixed by #37
Open

BUG - performLogin called multiple times #35

andrepcg opened this issue Nov 23, 2017 · 1 comment · May be fixed by #37

Comments

@andrepcg
Copy link

andrepcg commented Nov 23, 2017

If you dispatch multiple actions when cognito.state is LOGGING_IN, performLogin is going to be called a number of times equal to the number of actions dispatched.

This happens because the enable function is subscribed to the store and it runs every time an action is dispatched. The, identityPoolLogin is going to be called multiple times and the validation state.cognito.state === CognitoState.LOGGING_IN can be true for a few milliseconds, thus performing login multiple times

@andrepcg andrepcg changed the title Multiple performLogin called BUG - performLogin called multiple times Nov 23, 2017
@orther
Copy link

orther commented Dec 4, 2017

I noticed this bug too but I hadn't tracked down the cause. After reviewing policy.js it looks like you're correct. An easy solution would be to use observerStore (described here reduxjs/redux#303 (comment)) to only call the listeners when state.cognito.state changes/transitions.

@orther orther linked a pull request Dec 4, 2017 that will close this issue
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 a pull request may close this issue.

2 participants