Skip to content

fix: prevent dispatchEvent crash on uninitialized channels via muteStatus#1740

Merged
oliverlaz merged 1 commit into
masterfrom
fix/uninitialized-channel-mute-status-crash
May 12, 2026
Merged

fix: prevent dispatchEvent crash on uninitialized channels via muteStatus#1740
oliverlaz merged 1 commit into
masterfrom
fix/uninitialized-channel-mute-status-crash

Conversation

@oliverlaz
Copy link
Copy Markdown
Member

@oliverlaz oliverlaz commented May 12, 2026

CLA

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

Description of the changes, What, Why and How?

Fixes #1732.

When a message.new arrives for a channel that's in activeChannels but hasn't been watched yet, dispatchEvent throws. Happens during deep-link navigation (gap between client.channel(...) and .watch() resolving) and on screens that fetch via query({ watch: false }) and never watch.

The crash path is dispatchEvent → _handleChannelEvent → _countMessageAsUnread → muteStatus() → _checkInitialized(). _countMessageAsUnread is internal bookkeeping but was going through the public muteStatus() which gates on initialization. The throw escapes _handleChannelEvent and kills the rest of the dispatch cycle, so listeners and the offline-db handler for that event never run.

@github-actions
Copy link
Copy Markdown
Contributor

Size Change: +6 B (0%)

Total Size: 381 kB

📦 View Changed
Filename Size Change
dist/cjs/index.browser.js 127 kB +2 B (0%)
dist/cjs/index.node.js 128 kB +2 B (0%)
dist/esm/index.mjs 126 kB +2 B (0%)

compressed-size-action

@oliverlaz oliverlaz merged commit eea0a47 into master May 12, 2026
6 checks passed
@oliverlaz oliverlaz deleted the fix/uninitialized-channel-mute-status-crash branch May 12, 2026 09:28
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.

Race condition: dispatchEvent crashes on uninitialized channels via _checkInitialized in muteStatus

2 participants