You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: ChannelInner calls channel.getConfig() during render on a disconnected channel → "You can't use a channel after client.disconnect() was called" #3254
const [channelConfig, setChannelConfig] = useState(channel.getConfig());
If the channel is already disconnected (current user removed / channel deleted), getConfig() → getClient() throws You can't use a channel after client.disconnect() was called.
Two things make this worse than a one-off:
A useState initial argument is evaluated on every render, not only on mount (it is a plain eager argument, not a lazy initializer). So a mounted whose channel got disconnected throws on every subsequent re-render.
The throw happens in the render phase, so it propagates to the nearest error boundary and tears down the surrounding subtree.
Same class as #2393 and #3248. #3227 added channel.disconnected guards elsewhere in this very component — the mark-read effect (L305) and loadMore (L605) — but this render-time call was missed. The other getConfig() call at L472 is inside a try/catch that dispatches setError, so that one is fine.
To Reproduce
Render ….
Disconnect the channel: have the server emit channel.deleted or notification.removed_from_channel, so stream-chat runs activeChannels[cid]._disconnect() and sets channel.disconnected = true (calling channel._disconnect() directly reproduces it too).
Trigger any re-render while is still mounted (e.g. a state update in the parent).
Error is thrown during render.
Stack (abridged, React 19 dev build):
Error: You can't use a channel after client.disconnect() was called
at Channel.getClient (stream-chat)
at Channel.getConfig (stream-chat)
at ChannelInner (stream-chat-react)
at renderWithHooks
at updateFunctionComponent
at beginWork
Expected behavior
Rendering ChannelInner for an already-disconnected channel should not throw — consistent with the guards added in #3227.
Suggested fix:
const [channelConfig, setChannelConfig] = useState(() =>
channel.disconnected ? undefined : channel.getConfig(),
);
The lazy initializer also stops the call from re-running on every render, which is desirable independently of the guard.
Package version
stream-chat-react: 14.9.0 (offending code still present on master and v14.10.0)
stream-chat-js: 9.50.2
Desktop
disconnected is flipped from an asynchronous WS event, so there is always a window between the flag becoming true and React unmounting the . Any render inside that window crashes, which is why this is hard to fully avoid from outside the SDK.
Activity
fix(Channel): guard render-phase channel.getConfig() against disconne…
oliverlaz commentedon Aug 6, 2026
hi @minhth1529, thanks for raising this issue. I merged a fix for it, and it will be included in the next release by the end of this week.
chore(release): 14.11.0 [skip ci]
stream-ci-bot commentedon Aug 7, 2026
🎉 This issue has been resolved in version 14.11.0 🎉
The release is available on:
Your semantic-release bot 📦🚀
test(Channel): cover #3254 disconnected-channel render safety