xmtp-flutter
xmtp-flutter copied to clipboard
Bug: Stream of new messages does not emit all new messages
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.
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.