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

fix(datastore): Prevent stop from interrupting subsequent start call #2569

Merged
merged 4 commits into from
Aug 23, 2023

Conversation

mattcreaser
Copy link
Member

  • PR title and description conform to Pull Request guidelines.

Issue #, if available:
#1690

Description of changes:

  • Ensure that a websocket that is in the process of being closed is not re-used to start new subscriptions. This fixes the following code sample from our docs:
Amplify.DataStore.stop(
        {
            Amplify.DataStore.start(
                { Log.i("MyAmplifyApp", "DataStore started") },
                { Log.e("MyAmplifyApp", "Error starting DataStore", it) }
            )
        },
        { Log.e("MyAmplifyApp", "Error clearing DataStore", it) }
    )

NB: There is a caveat that this fix works as expected for the above code snippet, but it does not necessarily work if there are multiple levels of stop/start calls nested within each other.

How did you test these changes?

  • Verified that calling start from the stop callback now starts all subscriptions as normal.

Documentation update required?

  • No
  • Yes (Please include a PR link for the documentation update)

General Checklist

  • Added Unit Tests
  • Added Integration Tests
  • Security oriented best practices and standards are followed (e.g. using input sanitization, principle of least privilege, etc)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mattcreaser mattcreaser requested a review from a team as a code owner August 22, 2023 17:42
@mattcreaser mattcreaser enabled auto-merge (squash) August 22, 2023 21:03
@codecov-commenter
Copy link

Codecov Report

Merging #2569 (b45a1ae) into main (be07335) will increase coverage by 0.00%.
The diff coverage is 50.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@           Coverage Diff           @@
##             main    #2569   +/-   ##
=======================================
  Coverage   41.15%   41.15%           
=======================================
  Files         874      874           
  Lines       27625    27635   +10     
  Branches     3880     3880           
=======================================
+ Hits        11368    11373    +5     
- Misses      15033    15040    +7     
+ Partials     1224     1222    -2     

@mattcreaser mattcreaser merged commit e6c2aa1 into main Aug 23, 2023
1 check passed
@mattcreaser mattcreaser deleted the mattcreaser/closing-websocket branch August 23, 2023 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants