fix(realtime): wait for subscribe ack before returning#1386
fix(realtime): wait for subscribe ack before returning#1386Dodothereal wants to merge 1 commit intosupabase:mainfrom
Conversation
|
@olirice @silentworks could you please review this bugfix for #1209 when you have time? Thanks. |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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)
Comment |
|
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. |
Summary
AsyncRealtimeChannel.subscribe()wait for a definitive subscribe outcome before returningSUBSCRIBED,CHANNEL_ERROR,TIMED_OUT) in an internal futureawait subscribe(...)instead of returning earlyWhy
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 insrc/realtime)make realtime.mypyuv run ruff check src/realtime/src/realtime/_async/channel.py src/realtime/tests/test_channel.pyCloses #1209