Commit 00a0cf2
shelley/server: de-flake TestExecTerminal_ControlCharacters
Prompt: Run a demo server / Push with bin/q / Try again with —retries 2.
Separately see if you can make the test not flaky.
The control-character pty test intermittently failed in CI with empty
"cat -v output". Root cause: the read loop wrapped each wsjson.Read in a
200ms cancellable sub-context. With coder/websocket, a Read whose context
is cancelled fails the *whole connection* — so under CI CPU contention the
first premature 200ms timeout (before the pty spawned and cat emitted any
output) permanently poisoned the websocket; every subsequent read then
errored and the buffer stayed empty, tripping the failure.
Read on the single outer context instead (already bounding the whole test,
now 15s), so a slow first byte just blocks rather than killing the socket.
Also wait for the server's "attached" handshake before sending Ctrl-B so
the pty (and cat -v) is guaranteed running and can't drop the keystroke.
Verified: 120 iterations pass under heavy CPU load (GOMAXPROCS=1 with the
box saturated by `yes` workers), where the symptom is reproducible.
Co-authored-by: Shelley <shelley@exe.dev>1 parent 93c705e commit 00a0cf2
1 file changed
Lines changed: 23 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
349 | | - | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
350 | 357 | | |
351 | 358 | | |
352 | 359 | | |
| |||
360 | 367 | | |
361 | 368 | | |
362 | 369 | | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
369 | 373 | | |
370 | | - | |
371 | | - | |
372 | | - | |
| 374 | + | |
| 375 | + | |
373 | 376 | | |
374 | | - | |
375 | | - | |
376 | | - | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
377 | 387 | | |
378 | 388 | | |
379 | 389 | | |
| |||
384 | 394 | | |
385 | 395 | | |
386 | 396 | | |
387 | | - | |
388 | 397 | | |
389 | 398 | | |
390 | 399 | | |
| |||
0 commit comments