xmtp-flutter icon indicating copy to clipboard operation
xmtp-flutter copied to clipboard

Bug: Stream of new messages does not emit all new messages

Open bselwe opened this issue 2 years ago • 2 comments

Describe the bug

When the stream of messages streamBatchMessages is idle for 5-15 minutes (there is no new message received within that time), it sometimes fails to emit all new messages by skipping the first few messages.

CleanShot 2023-10-17 at 11 05 13@2x

Expected behavior

The stream of messages streamBatchMessages delivers all new messages in the given conversations.

Steps to reproduce the bug

listenToMessages(List<xmtp.Conversation> conversations) {
  recovery.cancel("messages");
  messagesSubscription?.cancel();
  messagesSubscription = client.streamBatchMessages(conversations).listen(
    (newMessage) async {
      debugPrint(
        '${DateTime.now()} [Conversations]: New message from ${newMessage.sender}: ${newMessage.content}',
      );

      send(NewMessageResponse(newMessage));
    },
    onError: (_) {
      recovery.cancel("messages");
      messagesSubscription?.cancel();
      recovery.attempt("messages", () => listenToMessages(conversations));
    },
  );
}

For recovery, see this.

bselwe avatar Oct 17 '23 09:10 bselwe