Skip to content

fix: increasing/decreasing member count on member event cause incorrect member count#1761

Open
szuperaz wants to merge 3 commits into
masterfrom
fix-member-count
Open

fix: increasing/decreasing member count on member event cause incorrect member count#1761
szuperaz wants to merge 3 commits into
masterfrom
fix-member-count

Conversation

@szuperaz
Copy link
Copy Markdown
Contributor

@szuperaz szuperaz commented Jun 2, 2026

The issue:
When adding more than one member at once to a channel, this is the WS event sequence I get:

  • Channel has 4 members now, we're adding 2 new members in a single API call
  • member.added event arrives -> stream-chat-js increases member count by one, current value is 5
  • channel.updated event arrives with member count 6 -> stream-chat-js sets member count from WS event to 6
  • member.added event arrives -> stream-chat-js increases member count by one, current value is 7 ❌

The solution:
Since channel.updated is dispatched every time we add/remove members, it's safe to set member count only from that event, and don't increase/decrease counter on member events.

CLA

  • I have signed the Stream CLA (required).
  • Code changes are tested

Description of the changes, What, Why and How?

Changelog

@MartinCupela MartinCupela changed the title fix: increasing/decreasing member count on member event cause incorre… fix: increasing/decreasing member count on member event cause incorrect member count Jun 2, 2026
Copy link
Copy Markdown
Contributor

@MartinCupela MartinCupela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@szuperaz could you add tests for this, please?

@szuperaz
Copy link
Copy Markdown
Contributor Author

szuperaz commented Jun 2, 2026

@szuperaz could you add tests for this, please?

Do you mean a negative test checking we don't change counter on member events?

@szuperaz
Copy link
Copy Markdown
Contributor Author

szuperaz commented Jun 2, 2026

@szuperaz could you add tests for this, please?

Added tests in this commit: f1db7dc

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

Size Change: -148 B (-0.04%)

Total Size: 393 kB

📦 View Changed
Filename Size Change
dist/cjs/index.browser.js 131 kB -49 B (-0.04%)
dist/cjs/index.node.js 132 kB -49 B (-0.04%)
dist/esm/index.mjs 130 kB -50 B (-0.04%)

compressed-size-action

@MartinCupela MartinCupela self-requested a review June 4, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants