Repository navigation
Conversation
Session and machine list updates, cu_permissions, send_to_device and the app-level ping reach every connection at once: deliver() builds every frame, takes every place in one pass, and sends to each connection in its own task. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SPdoY5jgXgTw6gUHBMBngR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four paths sent to one connection after another, so each connection waited out the drain of the one before it. A viewer whose phone stopped reading held the next viewer's session list up by its whole drain (1.005 s behind a 1.0 s drain). The four paths are session and machine list updates (
hub.py),cu_permissions(daemon.py) and a device's own frames (ws.pysend_to_device). Each now reaches every connection at once. So does the app-level ping, which the review found doing the same.What changes
core/tstd/ws.py:deliver(frames): each connection gets its own frame. Every frame is built first, then every place in a connection's send line is taken in one pass before any send, as a broadcast's are (TD-5446), so a later frame never overtakes it. Each connection is then sent to in its own task. A connection that closed meanwhile is skipped.broadcastanddelivershare that sending step (_send_all).send_to_device,Hub._on_rows,Hub._on_machinesandDaemon._emit_cu_permissionsusedeliver.core/tests/test_reply_funnel_off_loop.py, next to TD-5446's:send_to_deviceskips a closed connection.docs/tst-desk-backlog.md: TD-5452 entry.Before / after
e2e/td5452/test_td5452_fanout_probe.pycalls each real path with two connections, the first draining for 1.0 s (results/td5452-fanout-probe.out):cb20b685: when B gets its framehub._on_rows(session list)hub._on_machines(machine list)daemon._emit_cu_permissionsws.send_to_deviceApp-level pings (
e2e/td5452/ping_probe.py,results/td5452-ping-probe.log), with a 0.05 s interval and one reader draining 1.0 s: in 0.4 s the other client gets 1 ping on main and 7 here. The stuck reader gets 1 on both, so nothing piles up behind it.Question
The ticket's last point is left as it is: a broadcast still returns only once its slowest connection has its frame, so a producer that sends two in a row waits out a slow reader between them. That covers two broadcasts, and also two session-list updates, now that those are deliveries, so the second reaches the other connections that much later. Within one broadcast or delivery, connections are sent to at once.
Returning sooner would remove the only thing that slows a producer down to its slowest reader. A reader that is alive but slow would then collect frames with no bound; the ping loop closes only dead ones.
I recommend (B), with the limit set from a measurement. Your call.
Independent review
A separate reviewer, given the diff, the ticket and main's probes, wrote its own probes. Verdict: FIX FIRST, all fixed:
delivertook each place while it read its frames. Aframe_forthat raised for a later connection (send_to_device) left the earlier connections a ready place that never sent, so their later pushes hung until they disconnected. Not seen in production:frame_forthere is defensive. Every frame is now built first, and a test covers it.Checked by the reviewer, nothing found:
cu_permissionsnow goes on past a failing connection, where it used to stop.Re-review of the fixes: the code fixes are correct. Both new tests fail on the code before the fixes and pass after.
results/td5452-cancel-test-guard.log).Tests
tests/test_reply_funnel_off_loop.py: 36 passed. The two tests for the review's findings fail on the commit before the fixes .cu_permissionsor pings: 1,990 passed, 1 skipped on the final commit (results/td5452-related-tests-r4.log).test_two_daemons.py::test_self_pairing_shows_every_row_twice_and_the_remote_copy_survivesfailed 3 of 3 times. Itsask(list_machines)was taking a pushedmachine_listframe and discarding thesession_listit later waited for, because the single-connection push now came one loop turn later. Sending one connection in place, as main does, fixed it (3 of 3 passed alone, and it passed in both related runs since). The test itself is unchanged.Checks
release_scan --git: 0 hits.🤖 Generated with Claude Code
https://claude.ai/code/session_01SPdoY5jgXgTw6gUHBMBngR