For a Node.js video-call service, I keep the participant list on the server, clean up empty rooms from the same expiry data, and treat a disconnect as a lease that must expire. In a media editor that also hosts calls, presence accuracy is the deciding constraint: a stale cursor or a ghost caller is more damaging than a room that disappears a few seconds late.
Short answer: keep one authoritative membership record per room, attach a monotonically increasing connection epoch to every join, and remove a member only when its heartbeat lease expires or its current epoch closes. The list endpoint reads that record. Cleanup runs from the same expiry data, so listing and deletion cannot disagree.
How can a Node.js list keep participants and clean empty rooms?
A participant is a logical person, not a TCP socket. One person can open a second tab, switch networks, or reconnect while the old connection is still visible to the process.…