-
-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Realtime] RealtimeV2 broadcastStreams skip every other "Broadcast" #390
Comments
Hi @mkaulfers I made a few tests and I was able to implement the broadcast without losing any event. Here is my test implementation: import Supabase
import Foundation
let supabase = SupabaseClient(
supabaseURL: URL(string: "https://PROJECT_KEY.supabase.co")!,
supabaseKey: "ANON_KEY"
)
let channel = await supabase.channel("scan") {
$0.broadcast.receiveOwnBroadcasts = true
}
await channel.subscribe()
struct Payload: Codable {
let value: Int
}
Task {
for await event in await channel.broadcastStream(event: "scan_result") {
guard let payload = try? event["payload"]?.decode(as: Payload.self) else {
print("Raw event", event)
continue
}
print("Event received", payload)
}
}
await Task.yield()
for i in 0..<Int.max {
let message = Payload(value: i)
try await channel.broadcast(event: "scan_result", message: message)
print("Event sent", message)
try await Task.sleep(for: .seconds(1))
} Here are a few things I noticed in your code:
Please, review my sample and your code, and let me know what the results are. Thanks. |
Okay so I played around with this quite a bit more and have some additional context. I Implemented the |
If you're concerned about having too many open channels, you can use a single channel named |
Bug report
Describe the bug
There is an issue, with RealtimeV2 where performing a broadcast, is only received by listeners (
broadcastStream
) every other broadcast. For examplen % 2 != 0
broadcasts. here is an example of a broadcaster, and a listener that I have setup in my project that reproduces this issue. It exists in an@Environment(DataManager.self)
object, so it's never reinitialized while the app is running and I've confirmed that the task does indeed always exist.To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
1, 3, 5, 6, etc..
broadcasts, but will not receive2, 4, 6, etc..
broadcasts.Expected behavior
System information
Additional context
What my code above is attempting to do, is scan a QR on one device, from another, and it should notify the scanned device that it was either successful or failed.
The text was updated successfully, but these errors were encountered: