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
RpcServer disconnects cannot be observed without competing with cleanup #8461
RpcServer.Protocol.disconnects is exposed as a Queue.Dequeue<number>, but RpcServer.make also consumes that queue internally to interrupt a disconnected client's in-flight handlers. An application that takes from the queue to observe passive disconnects competes with the server and can prevent handler cleanup.
The repro uses a minimal in-memory protocol and runs a control plus a competing-observer case. It synchronizes on queue takers and handler lifecycle signals directly; no timing sleeps are involved.
Output:
control: both disconnected handlers were interrupted
competing observer: observer stole client 1; only client 2 was interrupted
Expected
There is a non-destructive way to observe passive client disconnects while preserving RpcServer.make's lifecycle handling.
Actual
The event-like API is the same work-sharing queue used by the server. Queue.take(protocol.disconnects) can steal a notification, so server.disconnect(clientId) is not called and that client's handler remains active. Protocol.clientIds is a snapshot and cannot provide equivalent event observation.
An additive callback on RpcServer.make (invoked after the server handles a disconnect) could expose this without changing the Protocol transport shape or queue semantics.
This was reproduced with [email protected], and the same single-consumer flow is present on current main.
Related: #7342 fixed another path where a lost disconnect prevented handler cleanup.
Activity