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
{{ message }}
Repository navigation
Agent.presenceRequests keeps a p: null entry for every presence that has left #764
Agent._broadcastPresence stores every presence that gets through receivePresence middleware in presenceRequests[channel][id], and that includes p: null leaves. Entries are only dropped when the client unsubscribes from the channel or disconnects. So a long-lived connection that creates and destroys presences with fresh ids, such as one LocalPresence per doc with a generated id, keeps a dead entry for every id until it disconnects.
The null entries do no work. Since #751, the leave broadcast skips them. Their only remaining job is the pv comparison, which stops an older presence that finishes middleware later from being stored over the leave.
Suggested fix
When a presence leaves, drop its entry, and the channel's map once it's empty, instead of storing it. Dropping the entry also loses its pv, which #763 needs in order to tell that a late presence is stale. So keep the entry only while a broadcast for the same id is still in flight, and drop it once that broadcast finishes.
The fix here has to keep an entry per id while a broadcast for it is still in flight, so that #763 can still read its pv. That's the per-channel "stored and in-flight requests" state #765 proposes, so it'd be simpler to fix this as part of #765 than to add another one-off map for it here.
Note that "since #751" only holds once #751 merges: on main, the 'end' handler still re-broadcasts the null entries.
Activity
alecgibson commentedon Oct 15, 2026
The fix here has to keep an entry per id while a broadcast for it is still in flight, so that #763 can still read its
pv. That's the per-channel "stored and in-flight requests" state #765 proposes, so it'd be simpler to fix this as part of #765 than to add another one-off map for it here.Note that "since #751" only holds once #751 merges: on
main, the'end'handler still re-broadcasts the null entries.alecgibson commentedon Oct 15, 2026
Folded into #765.
Agent's per-channel presence state in one place #765