Skip to content

fix(realtime): wait for subscribe ack before returning#1386

Closed
Dodothereal wants to merge 1 commit intosupabase:mainfrom
Dodothereal:codex/fix-issue-1209-subscribe-await
Closed

fix(realtime): wait for subscribe ack before returning#1386
Dodothereal wants to merge 1 commit intosupabase:mainfrom
Dodothereal:codex/fix-issue-1209-subscribe-await

Conversation

@Dodothereal
Copy link

Summary

  • make AsyncRealtimeChannel.subscribe() wait for a definitive subscribe outcome before returning
  • capture subscribe outcomes (SUBSCRIBED, CHANNEL_ERROR, TIMED_OUT) in an internal future
  • propagate callback exceptions through await subscribe(...) instead of returning early
  • add unit tests verifying: (1) subscribe does not return before ack, and (2) callback exceptions are raised to caller

Why

Issue #1209 reports await channel.subscribe(callback) returning before the server reply is handled, causing race conditions. This change ensures await semantics match subscription acknowledgement lifecycle.

Testing

  • uv run --package realtime pytest tests/test_channel.py tests/test_timer.py (run in src/realtime)
  • make realtime.mypy
  • uv run ruff check src/realtime/src/realtime/_async/channel.py src/realtime/tests/test_channel.py

Closes #1209

@Dodothereal
Copy link
Author

@olirice @silentworks could you please review this bugfix for #1209 when you have time? Thanks.

@coderabbitai
Copy link

coderabbitai bot commented Feb 8, 2026

Warning

Rate limit exceeded

@Dodothereal has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 16 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@o-santi
Copy link
Contributor

o-santi commented Feb 9, 2026

Hey @Dodothereal, thanks for the PR. I'm afraid we cannot merge this as of now because it would be breaking for most clients. People write their clients assuming that it doesnt block nowadays, so their code would be most likely wrong after this.

I intend to fix this problem, together with some other ones in realtime, in the next v3 version (#1370). Feel free to ask any other improvement that may be a breaking change there too.

@o-santi o-santi closed this Feb 9, 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.

AsyncRealtimeChannel.subscribe returns without waiting for an answer

2 participants