Skip to content

fix(realtime): correct channel removal and token refresh - #49

Merged
zoedsoupe merged 2 commits into
mainfrom
fix/realtime-w4-correctness
Nov 17, 2026
Merged

zoedsoupe merged 2 commits into
mainfrom
fix/realtime-w4-correctness

Conversation

@zoedsoupe

Copy link
Copy Markdown
Member

Problem

  • remove_all_channels called its own Registry through unsubscribe, causing an immediate :calling_self exit instead of leaving the channels.
  • Stable open connections did not refresh callback-based access tokens on heartbeat, so joined channels could retain an expired token until a manual update or rejoin.

Solution

  • For W4 R3, move each channel to leaving, cancel its rejoin timers and process the batch in handle_continue, reusing the existing leave behavior without a self-call.
  • For W4 R2, refresh access_token_fn during a healthy heartbeat; persist and push only a changed callback token to joined channels.
  • Add regressions for removing multiple channels, refreshing a joined channel and leaving static tokens without callback-triggered pushes. Tests: 325 passing in realtime-ex.

Rationale

Continuation-based removal preserves the existing connected and disconnected leave semantics without nested GenServer calls. Refreshing only callback tokens on the heartbeat send path avoids extra pushes for static or manual tokens and leaves timeout, reconnection and telemetry behavior unchanged. This PR excludes deferred realtime work and does not release the package.

@zoedsoupe
zoedsoupe merged commit 8ac71d0 into main Nov 17, 2026
24 checks passed
@zoedsoupe
zoedsoupe deleted the fix/realtime-w4-correctness branch November 17, 2026 20:36
@zoedsoupe zoedsoupe mentioned this pull request Nov 17, 2026
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.

1 participant