You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constserver=Bun.serve({port: 3001,fetch(req){server.upgrade(req)return},websocket: {open(ws){ws.subscribe('some-topic')ws.publish('some-topic','Message published by ws.publish()...')server.publish('some-topic','Message published by server.publish()...')}}})newWebSocket('ws://localhost:3001').onmessage=console.log
What is the expected behavior?
ws.publish('some-topic') should be sent to all other websockets connected to that topic, but not the sending websocket itself
What do you see instead?
It sends to all websockets in the topic, including self.
Additional information
A few months ago I asked about websocket pub/sub and whether or not published messages get echo'd back to the sender. I think @Jarred-Sumner found that they did, but shouldn't, and that you were working on a fix. The current docs say "...and .publish() messages to all other subscribers to that topic" which suggests they shouldn't as well. Just testing it now, looks like they do currently echo back to the sender though. Is there a workaround or fix in progress?
The text was updated successfully, but these errors were encountered:
Check out the publishToSelf option in the weboscket object handler. It's not enabled by default because it is a subtle breaking change and we want to avoid those. We could make this change in v0.6 though.
What version of Bun is running?
0.5.9
What platform is your computer?
WSL (Linux 4.19.104-microsoft-standard x86_64 x86_64)
What steps can reproduce the bug?
Sample code:
What is the expected behavior?
ws.publish('some-topic')
should be sent to all other websockets connected to that topic, but not the sending websocket itselfWhat do you see instead?
It sends to all websockets in the topic, including self.
Additional information
A few months ago I asked about websocket pub/sub and whether or not published messages get echo'd back to the sender. I think @Jarred-Sumner found that they did, but shouldn't, and that you were working on a fix. The current docs say "...and .publish() messages to all other subscribers to that topic" which suggests they shouldn't as well. Just testing it now, looks like they do currently echo back to the sender though. Is there a workaround or fix in progress?
The text was updated successfully, but these errors were encountered: