Closed aurecchia closed 7 months ago
Sorry for the double-post. Looking again at the broadcast protocol, it seems I might just be misunderstanding what the type
argument of the Send
method is supposed to represent.
If that has nothing to do with the event
property that subscribers are supposed to be using for listening to specific messages, then this bug report is completely wrong.
@aurecchia sorry for the delay getting to this one. I think you're right with the broadcast message type, specifically here: https://supabase.com/docs/guides/realtime/protocol#broadcast-message. The API has changed over time and this has probably been overlooked. I'll need to poke around a bit with the api - You're welcome to do a PR if you like!
No worries, there was no need to rush :)
I wasn't entirely sure, because the names used in the protocol and in the library are slightly different. If I find a bit of time, I'll give a go at putting together a fix 👍
Bug report
Hello folks. I encountered a problem and after some investigation I think there might be a slight problem with how realtime messages are serialized when being sent to sockets.
Describe the bug
Messages are serialized incorrectly when being broadcast. Specifically, the
type
property is "in the wrong place", which causes messages not to be picked up by subscribers.I had the issue when using the official JavaScript library on the subscriber side.
To Reproduce
Publish a message as follows:
which will be mapped onto the
SocketRequest
type and serialized to JSON (with the default encoder) as:On the receiving end, set up like so:
nothing will happen, as the JavaScript library expects the
type
property to be part ofpayload
, as described on the Broadcast Protocol page.Manually adding a
type
property as part of the payload causes the message to be processed correctly on the subscriber side.Interestingly, if I inspect the WebSockets connection in the browser, the
type
property is not even present:Expected behavior
It should be possible to consume messages from the JavaScript library.
System information