Skip to content

bug: a non-member-of-a-channel entering said channel will trigger an error due to the read state not existing #2753

@johnmccalla

Description

@johnmccalla

Describe the bug

When you enter a channel where you are not a member, an error appears in the console: "Failed to mark channel as read". The actual exception that is masked by the exception handler is: "Cannot read properties of null (reading 'last_read_message_id')". This is triggered by event being null here.

This appeared in v13 of the react sdk, and (I think) is due to this commit. The additions here assumes you need to update the read state of the channel if the last message you read isn't the last message in the channel. This makes sense for members of a channel, but will always say "yes, update read state" for non-members (because there will be null for expression channel.state.read[userId]). And since members don't have a read state, the event mentioned above is null.

To Reproduce

Enter any channel you're not a member of.

Expected behavior

Handles non-members viewing a channel without raising an error.

Package version

"stream-chat": "^9.9.0",
"stream-chat-react": "^13.2.1",

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreleased on @lateststatus:confirmedDescribed issue has been reproduced by the repo maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions