Skip to content

state.unreadChannelsStream sometimes returns an incorrect unread message count #2347

@kevingaulin

Description

@kevingaulin

Description

I’m using stream_chat_flutter: ^9.14.0 with a StreamChatClient.
When listening to state.unreadChannelsStream, the unread message count is not always correct — sometimes it returns 0 randomly, even when there are still unread messages.

Scenario

Application A: Flutter (Facebook-like app)

Application B: React Native (Messenger-like app)

Both apps are connected with the same Stream user.

Steps to reproduce:

In Application A, I have a deeplink button that opens Application B, showing a badge with the unread message count (e.g., 1).

I click the button → Application B opens.

In Application B, I can see the unread message, but I don’t read it.

I go back to Application A → the badge disappears (count becomes 0).

After some random amount of time, the badge reappears again with the correct count.

Observed behavior

While debugging state.unreadChannelsStream, I noticed that it sometimes emits 0 when switching to Application B (with or without using the deeplink), even though the message was never read.
This happens randomly but fairly often.

Expected behavior

state.unreadChannelsStream should always return the correct unread message count reliably, even when the same user is connected from multiple devices/applications.

Environment

Flutter: 3.32.8

stream_chat_flutter: 9.14.0

iOS / Android: both

Multi-device / multi-application with the same Stream user

Note
This bug seems related to unread state synchronization between multiple simultaneous connections for the same user.

notification_badge.mp4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions