Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: ChannelList shows two channels when the server creates one and sends a message to it at the same time #2664

Open
lukewilson2002 opened this issue Mar 6, 2025 · 3 comments
Assignees
Labels
bug Something isn't working pending-reply

Comments

@lukewilson2002
Copy link

lukewilson2002 commented Mar 6, 2025

Describe the bug

It's easier to describe how it happens in my Slack-like messaging app:

A user creates a channel, creating a POST request to my .NET server which uses the stream-chat-net library to create a channel and immediately sends the list of users that were added to the channel as a system message.

The user should see just one channel is added to the ChannelList, because the socket connection sends them an update when they're added to the channel.

Instead, the user sees two channels.

I can easily reproduce this if I'm using Slow 4G throttling in Chrome. Without throttling, I think that my client can see and respond to these millisecond-difference requests in time. When both requests are coming in at once, however, maybe there's a data race.

To Reproduce

On the client: connect to chat and watch channel list for updates, enable Slow 4G throttling for a simulated user experience.

On the server:

  1. Create a channel with the user watching as a member
  2. Send a system message immediately after

The user should see two channels that are identical in the ChannelList:

Two identical channels

And I do get an error from React in the console that the two ChannelPreviews have the same key.

Package version

  • stream-chat-react: 12.10.0
  • stream-chat-css:
  • stream-chat-js: 8.55

Desktop (please complete the following information):

  • OS: macOS
  • Browser Chrome
  • Version 133
@lukewilson2002 lukewilson2002 added bug Something isn't working status: unconfirmed labels Mar 6, 2025
@lukewilson2002
Copy link
Author

I've found that if I delay sending the message by just a second that it works flawlessly even on the slowest 3G throttling:

_ = Task.Run(async () => {
    await Task.Delay(1000);
    await SendSystemMessageAsync(response.Channel.Id, $"{identity.Name} created a {message}");
});

@arnautov-anton
Copy link
Contributor

arnautov-anton commented Mar 6, 2025

Hey, @lukewilson2002, thank you for your report - I believe I know what's the issue. I'll prepare a PR with the fix ASAP and once it's merged, the issue will get closed - we'll issue a release right after. :)

@arnautov-anton arnautov-anton added status:confirmed Described issue has been reproduced by the repo maintainer and removed status: unconfirmed labels Mar 6, 2025
@arnautov-anton arnautov-anton self-assigned this Mar 6, 2025
@arnautov-anton
Copy link
Contributor

Hey again, @lukewilson2002, my apologies - I missed the version of the SDK you're using! We've fixed the issue you reported in v12.11.0, please upgrade to the latest and let me know if the issue persists.

@arnautov-anton arnautov-anton added pending-reply and removed status:confirmed Described issue has been reproduced by the repo maintainer labels Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending-reply
Projects
None yet
Development

No branches or pull requests

2 participants