-
Notifications
You must be signed in to change notification settings - Fork 198
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
Delete publisher is not triggered on Amplify #2982
Comments
waiting for response |
@Umar009 Our team is prioritizing and will try to look into the issue. |
Hi @Umar009, I was able to reproduce the issue. I called DataStore.start to establish the subscriptions, and then put the iOS app in the background. Then I performed a create mutation followed by a delete mutation, while the app still in the background. ie.
Once I bring the app back to the foreground, I can see both events, one for the onCreate subscription and one for the onDelete subscription:
I've attached the remaining logs for a reference. logs2982.log It appears the DataStoreReconcileAndLocalSaveOperation is started with the version 1 object, and ends up inserting it into the database, while the delete event is not removing the version 1 object. The unexpected behavior I can see is in IncomingAsyncSubscriptionEventToAnyModelMapper. If two events comes in, and Subscribers.Demand of It looks like I am able to reproduce the behavior in a small smaple in https://gist.github.com/lawmicha/e13a7d1100ccbb618c0f86b58e93c184
I'm emitting the values 0 to 4 (like the subscription create and delete events). the intermediate subscriber controls the demand to receive one at a time, before reemitting it. It looks like it's due to the publisher emitting events faster than the subscriber can handle them. I can explore changing this code to perhaps use a buffer operator instead and see if it will fix the problem. Even if this problem is fixed, we can't guaranteed that the events that were sent from the server are processed by the app while it's in the background. Once the websocket connetion is closed, DataStore will eventually catch up through the delta sync process. |
@Umar009 One thing you can try in the meantime is to see if you can hook into the app lifecycle methods when it goes into foreground, or in did become active:
Calling stop then start will cause it to re-establish the subscriptions and more importantly perform the sync query calls to catch up the data. The deleted record should be in the sync query response, and will reconcile and remove the local model. |
We are observing very similar issue but it is not related to deletion but rather updating an objects and it does not happen when app is in the background but is fully in foreground. Sample case:
|
Our team is still investigating the issue. We will provide an update as soon as we have more information. |
@fzy-spyro and @Umar009 A fix has been released in https://github.com/aws-amplify/amplify-swift/releases/tag/2.26.2 .. |
|
Describe the bug
We integrated Amplify into our project for Android, iOS, and the web portal. We use Amplify for user sign-in and to store user data. However, we encountered an issue with the iOS app. While it works perfectly fine when iOS App is in active state, creating, deleting, or editing user item entries from the web or Android app get updated real time in iOS App, there is a problem when the iOS app is in the background or closed.
Specifically, when a user creates a new entry and then deletes it while the app is in the background or closed, upon opening the app either from the background or a fresh launch, the create event is triggered, but the delete event is not called. Interestingly, if a user edits an item, the event for the edit is called.
It's important to note that if an item is already added, and then the app is moved to the background and the device screen is locked, deleting that item from the web portal or Android app will trigger the delete event when the iOS app comes back from the background.
Steps To Reproduce
Expected behavior
Delete event must be triggered on amplify and item must be deleted from Amplify data store
Amplify Framework Version
1.22.2
Amplify Categories
DataStore
Dependency manager
Cocoapods
Swift version
5
CLI version
10.7.3
Xcode version
14.2
Relevant log output
Is this a regression?
No
Regression additional context
I don't know. I just encounter this issue
Device
iphone Se 2020
iOS Version
15.4
Specific to simulators
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: