Skip to content

fix(realtime): fail a presence call at once when its channel closes or errors - #2237

Merged
spydon merged 3 commits into
supabase:mainfrom
Franklyn-R-Silva:fix/realtime-fail-presence-on-channel-close
Dec 2, 2026
Merged

spydon merged 3 commits into
supabase:mainfrom
Franklyn-R-Silva:fix/realtime-fail-presence-on-channel-close

Conversation

@Franklyn-R-Silva

Copy link
Copy Markdown
Contributor

A track() or untrack() waiting for its reply now resolves with ChannelResponse.error as soon as its channel closes or errors, instead of waiting for its timeout and resolving with timedOut.

Closes #2236

  • The channel keeps the presence pushes it sent in _presencePushes, and each one leaves the set once its call completes. When the channel closes or errors, it settles each of them with Push.trigger(PushStatus.error, {}), as _onClose already does for the buffered pushes. That also cancels their timeout timer.
  • Only presence calls fail early, as the presence specs require. Other pushes, such as a broadcast with ack, keep waiting for their own timeout.
  • The doc comments of track and untrack mention the new outcome.
  • The new tests in rejoin_test.dart send a track that gets no reply and then a phx_close or a phx_error from the server, and check that the call resolves with error right away. Both fail without the fix.

…r errors

A track or untrack sent on a joined channel waited for its reply until
its timeout, even after the channel closed or errored, and then resolved
with timedOut. No reply can arrive by then, and the server closes the
channel instead of replying when a client exceeds its presence rate or
size limits. The channel now keeps the presence pushes waiting for a
reply and fails them with ChannelResponse.error when it closes or
errors.
Copilot AI balanced review requested due to automatic review settings December 2, 2026 14:42
@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 02b9524 and 9f3550e.

Files selected for processing: 2

  • packages/supabase_realtime/lib/src/realtime_channel.dart
  • packages/supabase_realtime/test/rejoin_test.dart
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@spydon
spydon merged commit 1482b07 into supabase:main Dec 2, 2026
55 checks passed
spydon added a commit that referenced this pull request Dec 2, 2026
…per (#2245)

Simplifies how the channel tracks presence pushes awaiting a reply, a
follow-up to #2237.

- One local `complete` in `send()` settles the call and drops the push
from the pending set, replacing the unawaited `whenComplete` per call
and four copies of the completer check.
- Clear the set before failing its pushes, like the push buffer on
close.

Closes SDK-3300

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved handling of pending presence updates when a channel send
fails, reducing the risk of stale updates or incomplete responses.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

Presence track/untrack waits for its timeout after the channel closes or errors

3 participants