Messages sent using the Realtime Broadcast service are sent and received, but the supabase-js client will never invoke the corresponding event listener.
The issue seems to be on this line:
https://github.com/supabase/supabase-js/blob/master/packages/core/realtime-js/src/RealtimeChannel.ts#L874
As bind.callback(handledPayload, ref) returns a function (the event listener), so it should be bind.callback(handledPayload, ref)() for the event listener to be invoked.
To Reproduce
I have an app where users are able to join a group and broadcast messages to that group. This is the relevant code, based on the examples in Supabase's docs:
await supabseClient.realtime.setAuth();
const channel = supabseClient.channel('test', {
config: {
broadcast: { ack: true },
presence: { enabled: true },
private: false,
},
});
channel
.on(
'broadcast',
{ event: '*' },
(payload) => () => {
console.log(payload);
}
)
.subscribe(async (status) => {
if (status !== 'SUBSCRIBED') return;
await channel.track(user)
await channel.send({
type: 'broadcast',
event: 'test',
payload: { foo: 'bar' },
});
});
The test event (or any other event I send, is never received by the broadcast * event handler on other instances of the app (e.g. I open the app in 2 different tabs and authenticate with 2 different users). I've also tried replacing { event: '*' } with { event: 'test' } and it doesn't work either.
However, if I use the Realtime Inspector on Supabase and join the "test" channel, the messages are actually received there, and I can also see it being received in the network tab in DevTools.
I've tested this in localhost only so far.
Expected behavior
The broadcast event handler receives messages sent from other instances.
System information
- OS: Windows
- Browser: Chrome
- Version of supabase-js:
2.86.0
- Version of Node.js:
v22.17.0
Library affected
supabase-js
Reproduction
No response
Steps to reproduce
No response
System Info
System:
OS: Linux 5.10 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
CPU: (20) x64 12th Gen Intel(R) Core(TM) i9-12900HK
Memory: 28.53 GB / 31.20 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 22.17.0 - /home/usr/.nvm/versions/node/v22.17.0/bin/node
Yarn: 1.22.19 - /mnt/c/Program Files/nodejs/yarn
npm: 11.5.1 - /home/usr/.nvm/versions/node/v22.17.0/bin/npm
pnpm: 10.19.0 - /home/usr/.local/share/pnpm/pnpm
bun: 1.1.17 - /home/usr/.bun/bin/bun
npmPackages:
@supabase/ssr: ^0.7.0 => 0.7.0
@supabase/supabase-js: ^2.86.0 => 2.86.0
Used Package Manager
pnpm
Logs
No response
Validations
Messages sent using the Realtime Broadcast service are sent and received, but the
supabase-jsclient will never invoke the corresponding event listener.The issue seems to be on this line:
https://github.com/supabase/supabase-js/blob/master/packages/core/realtime-js/src/RealtimeChannel.ts#L874
As
bind.callback(handledPayload, ref)returns a function (the event listener), so it should bebind.callback(handledPayload, ref)()for the event listener to be invoked.To Reproduce
I have an app where users are able to join a group and broadcast messages to that group. This is the relevant code, based on the examples in Supabase's docs:
The
testevent (or any other event I send, is never received by thebroadcast *event handler on other instances of the app (e.g. I open the app in 2 different tabs and authenticate with 2 different users). I've also tried replacing{ event: '*' }with{ event: 'test' }and it doesn't work either.However, if I use the Realtime Inspector on Supabase and join the
"test"channel, the messages are actually received there, and I can also see it being received in the network tab in DevTools.I've tested this in
localhostonly so far.Expected behavior
The broadcast event handler receives messages sent from other instances.
System information
2.86.0v22.17.0Library affected
supabase-js
Reproduction
No response
Steps to reproduce
No response
System Info
System: OS: Linux 5.10 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish) CPU: (20) x64 12th Gen Intel(R) Core(TM) i9-12900HK Memory: 28.53 GB / 31.20 GB Container: Yes Shell: 5.1.16 - /bin/bash Binaries: Node: 22.17.0 - /home/usr/.nvm/versions/node/v22.17.0/bin/node Yarn: 1.22.19 - /mnt/c/Program Files/nodejs/yarn npm: 11.5.1 - /home/usr/.nvm/versions/node/v22.17.0/bin/npm pnpm: 10.19.0 - /home/usr/.local/share/pnpm/pnpm bun: 1.1.17 - /home/usr/.bun/bin/bun npmPackages: @supabase/ssr: ^0.7.0 => 0.7.0 @supabase/supabase-js: ^2.86.0 => 2.86.0Used Package Manager
pnpm
Logs
No response
Validations