-
-
Notifications
You must be signed in to change notification settings - Fork 271
Description
When an iOS app goes in the background, it looses network after a while (about 90 seconds according to my tests with the simulator).
If new rows are then created in a Supabase table that the app listens to, the app doesn't receive the data (which is expected).
When the app reconnects after idling, it starts receiving table addition events (which is expected), but it emits a representation of the data without the events that happened while is was offline (which is not expected).
I looked a bit at the code and can see that supabase-flutter manages its own cache, and that it manages internal representations of a table on atomic events like "INSERT" for example.
Maybe a solution could be to fetch the whole table after a reconnection? Or maybe to pass a reference to the previous message for all atomic events, so that the app can ensure that it hasn't missed one?
See video below for an example: the "third message" is ignored, and an incorrect representation of the messages list is emitted.
https://github.com/supabase/supabase-flutter/assets/1177483/5b44500b-d3eb-476b-8946-f02d4029c8f4
Steps to reproduce the behavior:
- Listen to a table
supabase.from('messages').stream(primaryKey: ['id']).listen((event) {
setState(() {
_messages = event.map(Message.fromJson).toList();
});- Move the app to the background
- Wait 1:30 minute
- Add a row in the supabase table
- Bring the app to the foreground
- Add a row in the supabase table
Expected behavior
The stream emits a correct representation of the data.
Version:
I am on MacOS
dart pub deps | grep -E "supabase|gotrue|postgrest|storage_client|realtime_client|functions_client"
│ ├── supabase_flutter 2.0.0-dev.1
│ │ ├── supabase 2.0.0-dev.1
│ │ │ ├── functions_client 2.0.0-dev.0
│ │ │ ├── gotrue 2.0.0-dev.0
│ │ │ ├── postgrest 2.0.0-dev.0
│ │ │ ├── realtime_client 2.0.0-dev.1
│ │ │ ├── storage_client 2.0.0-dev.0