Repository navigation
Commit ae335ce
client: stop the stderr enrichment racing its own drainer
`_client_error_with_stderr` read `_stderr_buffer` the moment an error was
raised, but that buffer is filled by a daemon thread otherwise joined only
in `stop()`. Lose the race and the error carries no stderr at all -- so the
traceback the enrichment exists to surface is precisely the one most likely
to go missing, and a worker that died on startup reports a bare
"Tried reading schema message, was null or length 0".
Not theoretical: delaying the drainer by 50ms loses the output entirely,
and a machine saturated by `pytest -n auto` delays a daemon thread by far
more, which is how this reached CI as an intermittent failure of
test_error_includes_stderr_on_worker_failure.
Wait for the drainers, but only once every worker process has exited --
then the pipes are at EOF and the threads are microseconds from returning.
A live worker holds its pipe open and its drainer never returns at all, so
waiting there would stall every ordinary error (a bind rejection from a
perfectly healthy worker) for nothing. Measured: 0.0000s on that path with
a deliberately never-ending drainer.
Both halves are pinned by tests that force the timing rather than hoping
for it -- one delays the drainer 250ms and asserts the stderr still lands,
the other asserts enrichment returns while the drainer is provably still
blocked.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent fcf1d1b commit ae335ce
2 files changed
Lines changed: 96 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
| 87 | + | |
| 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 | + | |
85 | 146 | | |
86 | 147 | | |
87 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| 250 | + | |
| 251 | + | |
250 | 252 | | |
251 | 253 | | |
252 | 254 | | |
| |||
257 | 259 | | |
258 | 260 | | |
259 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
260 | 266 | | |
261 | 267 | | |
262 | 268 | | |
| |||
593 | 599 | | |
594 | 600 | | |
595 | 601 | | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
596 | 630 | | |
597 | 631 | | |
598 | 632 | | |
| |||
604 | 638 | | |
605 | 639 | | |
606 | 640 | | |
| 641 | + | |
607 | 642 | | |
608 | 643 | | |
609 | 644 | | |
| |||
0 commit comments