Commit fe957f1
committed
Fix WS handshake over-reading and dropping the next protocol frame
Root cause of the long-running CI flake on Windows + Python 3.13 in
test_ws_viewer_authenticates_and_receives_frames /
test_ws_host_announces_host_id and friends:
_read_http_message used recv(1024). On loopback the kernel often
coalesces the host's "101 Switching Protocols" reply and the
AUTH_CHALLENGE WS frame that follows it into a single TCP segment.
The bulk recv consumed both, the function returned only the HTTP
text, and the trailing frame bytes were silently dropped. The
client's next recv() then blocked the full 60 s auth budget waiting
for a frame the kernel had already delivered. This pattern is
load-dependent (server has to be fast enough to flush both back-to-
back), which is exactly why the failure looked random.
Switch to byte-by-byte reads up to "\r\n\r\n" so any post-header
bytes stay in the kernel buffer for the next recv. The extra
syscalls cost ~1 ms on loopback — well below the WS upgrade itself.
Also drop the @pytest.mark.flaky reruns added in 0929195: those were
masking this exact bug, and the underlying handshake is now
deterministic.
Add a regression test that fuses the 101 response and a WS BINARY
frame into one sendall and verifies recv_message still returns the
frame after client_handshake.1 parent 9a0924b commit fe957f1
2 files changed
Lines changed: 69 additions & 6 deletions
File tree
- je_auto_control/utils/remote_desktop
- test/unit_test/headless
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
105 | 113 | | |
106 | | - | |
107 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
108 | 117 | | |
109 | 118 | | |
110 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
89 | 147 | | |
90 | 148 | | |
91 | 149 | | |
| |||
114 | 172 | | |
115 | 173 | | |
116 | 174 | | |
117 | | - | |
118 | 175 | | |
119 | 176 | | |
120 | 177 | | |
| |||
131 | 188 | | |
132 | 189 | | |
133 | 190 | | |
134 | | - | |
135 | 191 | | |
136 | 192 | | |
137 | 193 | | |
| |||
145 | 201 | | |
146 | 202 | | |
147 | 203 | | |
148 | | - | |
149 | 204 | | |
150 | 205 | | |
151 | 206 | | |
| |||
166 | 221 | | |
167 | 222 | | |
168 | 223 | | |
169 | | - | |
170 | 224 | | |
171 | 225 | | |
172 | 226 | | |
| |||
0 commit comments