Currently, when an endpoint is created by updateEndpoint, it is not cached until a full network round trip to the service. This results in a large window during which additional updateEndpoint calls will create new endpoint ids due to none being found in the cache.
This PR adds a utility which will hold created endpoint ids in memory until it is successfully cached or if the endpoint updating has failed.
Added thrown error expectation to original code and asserted the resulting behavior of the updateEndpoint function is the same (async void which throws uncaught)
Tested in sample app and validated that network race condition was mitigated - the updateEndpoint calls triggered by initializePushNotifications and an adjacent identifyUser call were no longer creating separate endpoints.
Description of changes
Currently, when an endpoint is created by
updateEndpoint
, it is not cached until a full network round trip to the service. This results in a large window during which additionalupdateEndpoint
calls will create new endpoint ids due to none being found in the cache.This PR adds a utility which will hold created endpoint ids in memory until it is successfully cached or if the endpoint updating has failed.
Issue #, if available
https://github.com/aws-amplify/amplify-js/issues/13272
Description of how you validated changes
yarn test
updateEndpoint
function is the same (async void which throws uncaught)updateEndpoint
calls triggered byinitializePushNotifications
and an adjacentidentifyUser
call were no longer creating separate endpoints.Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.