Skip to content

[CLNP-8774] fix: prevent TypingIndicator from leaking group channel handlers on unmount - #1448

Open
sf-tyler-jeong wants to merge 2 commits into
mainfrom
fix/clnp-8774
Open

[CLNP-8774] fix: prevent TypingIndicator from leaking group channel handlers on unmount#1448
sf-tyler-jeong wants to merge 2 commits into
mainfrom
fix/clnp-8774

Conversation

@sf-tyler-jeong

Copy link
Copy Markdown
Contributor

What & why

TypingIndicator's useEffect cleanup removed the stale handlerId state
instead of the newHandlerId that was actually registered via
addGroupChannelHandler. The live GroupChannelHandler was therefore never
removed on unmount and leaked, accumulating across mount/unmount cycles (e.g.
repeated channel navigation). Originally reported in #1444.

Changes

  • Hoist newHandlerId into the effect scope so the cleanup removes the exact
    id it registered, falling back to handlerId when no handler was added.
  • Add a regression test covering unmount and channel-switch cleanup (fails on
    the previous code, passes with the fix).
  • Channel/components/TypingIndicator re-exports this component, so both
    module entry points are covered by the one change.

…nmount

The effect cleanup removed the stale `handlerId` state instead of the
`newHandlerId` that was actually registered, so the live GroupChannelHandler
leaked on unmount and accumulated across mount/unmount cycles.

Hoist `newHandlerId` into the effect scope so the cleanup removes the exact
id it registered, falling back to `handlerId` when no handler was added. Add
a regression test covering unmount and channel-switch cleanup.

CLNP-8774
Reported via #1444
@netlify

netlify Bot commented Jul 29, 2026

Copy link
Copy Markdown

Deploy Preview for sendbird-uikit-react ready!

Name Link
🔨 Latest commit 87246a8
🔍 Latest deploy log https://app.netlify.com/projects/sendbird-uikit-react/deploys/6a6b071e243a200008b9ed1d
😎 Deploy Preview https://deploy-preview-1448--sendbird-uikit-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

useEffect(() => {
let newHandlerId: string | undefined;
if (sb?.groupChannel?.addGroupChannelHandler) {
sb.groupChannel.removeGroupChannelHandler(handlerId);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

handlerId는 더 이상 사용되지 않는 것 같습니다.
최초에 생성될 때 uuid로 생성되고, unmount 시에는 cleanup에서 생성된 ID로 handler를 remove하기 때문에 handlerId가 의미가 없어 보입니다.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

수정했습니다. 감사합니다!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

이 부분도 더 이상 state로 handler를 관리하는 게 의미가 없어 보입니다.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

수정했습니다. 감사합니다!

After the handler-leak fix, the handlerId React state no longer serves a
purpose: the cleanup removes the exact id it registered via a local
variable, so the state (and the redundant remove at the start of the
effect body) was dead code. Keeping the id in state was in fact what made
the original add/remove ids diverge and leak.

Use a single local handlerId per effect run, registered and removed within
the same closure -- matching the pattern already used in
Thread/useHandleChannelEvents and the other channel handlers. Behavior is
unchanged and the CLNP-8774 regression test still passes.

Addresses review feedback on #1448.

CLNP-8774
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