Empty .to([]) sends to everybody instead of nobody
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- javascript, node.js, typescript
- Domain
- backend, networking
Research direction
Start with the server example using io.to([]).emit("hello") and trace the broadcast path for an empty target list. Confirm the behavior with connected clients, then verify that an empty array sends to no clients and that the behavior is covered by a regression test.
Written by the indexing model from the issue text.
Description
Describe the bug
io.to([]).emit("hello") sends to everybody instead of nobody
To Reproduce
Socket.IO server version: 4.6.1
Server
import { Server } from "socket.io";
const io = new Server(3000, {});
io.on("connection", () => {
io.to([]).emit("hello");
});
Socket.IO client version: 4.6.1
Client
import { io } from "socket.io-client";
const socket = io("ws://localhost:3000/", {});
socket.on("hello", () => {
console.log("hello received");
});
Expected behavior
I expect no message to be sent when an empty array is passed to .to().
Platform:
- OS: macOS 13.2
Additional context
It's easy to work around, but the behavior was unexpected.
- Dominant language
- TypeScript
- Stars
- 63.2k
- Forks
- 10.3k
- Avg merge
- 11d 20h
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from socketio/socket.io
-
question
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
question
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 56/100
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
All issues in socketio/socket.io
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
area:tools bug good first issue help wanted priority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
TaewoooPark/Motifcode#14 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
newrelic-experimental/preflight#793 · 1 comment ·
-
bug 🐞
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
[Bounty proposal] fix(web): memory insights count an evening memory on the next day ($25 proposed) Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
BasedHardware/omi#15320 ·