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(api): propagate connectionLost error from websocket client to sync engine #3800

Merged
merged 4 commits into from
Aug 9, 2024

Conversation

5d
Copy link
Member

@5d 5d commented Aug 7, 2024

Issue #

#3632

Description

When an app using the DataStore plugin switches from foreground to background, the network connection is aborted, and the URLSessionTaskDelegate will receive a connection lost error. This error should be propagated back to the remote sync engine to trigger a scheduling restart, ensuring all missing records are retrieved while the app is in the background without a connection.

General Checklist

  • Added new tests to cover change, if needed
  • Build succeeds with all target using Swift Package Manager
  • All unit tests pass
  • All integration tests pass
  • Security oriented best practices and standards are followed (e.g. using input sanitization, principle of least privilege, etc)
  • Documentation update for the change if required
  • PR title conforms to conventional commit style
  • New or updated tests include Given When Then inline code documentation and are named accordingly testThing_condition_expectation()
  • If breaking change, documentation/changelog update with migration instructions

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

@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest August 7, 2024 00:08 — with GitHub Actions Inactive
Copy link
Contributor

github-actions bot commented Aug 7, 2024

API Breakage Report

✅ No Public API Breaking Change detected

@5d 5d marked this pull request as ready for review August 7, 2024 00:45
@5d 5d requested a review from a team as a code owner August 7, 2024 00:45
Copy link

codecov bot commented Aug 7, 2024

Codecov Report

Attention: Patch coverage is 77.58621% with 13 lines in your changes missing coverage. Please review.

Project coverage is 68.69%. Comparing base (e41df42) to head (7027a44).

Files Patch % Lines
.../AppSyncRealTimeClient/AppSyncRealTimeClient.swift 66.66% 7 Missing ⚠️
...meClient/AppSyncRealTimeClient+HandleRequest.swift 85.29% 5 Missing ⚠️
...n/Operation/AWSGraphQLSubscriptionTaskRunner.swift 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3800      +/-   ##
==========================================
+ Coverage   68.52%   68.69%   +0.16%     
==========================================
  Files        1080     1080              
  Lines       37700    37692       -8     
==========================================
+ Hits        25834    25892      +58     
+ Misses      11866    11800      -66     
Flag Coverage Δ
API_plugin_unit_test 68.96% <77.19%> (+0.12%) ⬆️
AWSPluginsCore 68.67% <ø> (ø)
Amplify 47.36% <ø> (ø)
Analytics_plugin_unit_test 84.52% <ø> (ø)
Auth_plugin_unit_test 79.70% <ø> (-0.05%) ⬇️
DataStore_plugin_unit_test 82.36% <100.00%> (+0.93%) ⬆️
Geo_plugin_unit_test 72.00% <ø> (ø)
Logging_plugin_unit_test 62.95% <ø> (ø)
Predictions_plugin_unit_test 37.32% <ø> (ø)
PushNotifications_plugin_unit_test 86.21% <ø> (ø)
Storage_plugin_unit_test 76.81% <ø> (ø)
unit_tests 68.69% <77.58%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


await mockWebSocketClient.setStateToConnected()
Task {
try await Task.sleep(nanoseconds: 80 * 1_000_000)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need delays? does it ensure a deterministic flow of events?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, as the websocket is mocked. here is trying to mock the events flow.

@5d 5d merged commit 00aac42 into main Aug 9, 2024
138 checks passed
@5d 5d deleted the 5d/throw-network-error-appsyncRTC branch August 9, 2024 16:23
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.

2 participants