fix: concurrent credential storage errors by preventing unnecessary state updates #1302
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes issue #1278 where frequent
CRYPTO_EXCEPTION
errors were occurring on Android devices due to concurrent credential storage operations.Why
The issue was caused by multiple concurrent calls to
getCredentials()
triggering unnecessary state updates and credential saves. When the same token was being stored multiple times concurrently, it led to crypto exceptions on Android devices.The root cause was in the
getCredentials
method using theloginFlow
wrapper, which would always save the credentials again.How
deepEqual
function to compare user objects and detect actual changesSET_USER
action type that only updates state when the user object has actually changed (using deep equality comparison)loginFlow
wrapper to a direct implementation that:SET_USER
instead ofLOGIN_COMPLETE
Testing
getCredentials
calls no longer cause crypto exceptionsCloses #1278