Repository navigation
Commit 36bb4ba
fix(client): default encoding_error_handler to "replace"
StdioServerParameters.encoding_error_handler defaulted to "strict", which
TextReceiveStream uses when decoding the server's stdout. A single invalid
UTF-8 byte raised UnicodeDecodeError inside stdout_reader's receive loop;
that error matches none of the handler's except clauses, so it escaped the
task group and brought the whole transport down as an ExceptionGroup, losing
any valid message that followed.
The shutdown drain already consumes raw bytes, so only the mid-session path
was affected. Defaulting to "replace" makes the malformed bytes U+FFFD, which
then fails JSON-RPC validation, and _parse_line returns that error as a value
on the read stream -- the established behaviour for an unparseable line. The
session stays up and later messages still arrive.
This matches the server side, hardened the same way in #2302.
Fixes #2454
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 77001c9 commit 36bb4ba
2 files changed
Lines changed: 30 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
111 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
112 | 116 | | |
113 | 117 | | |
114 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
326 | 350 | | |
327 | 351 | | |
328 | 352 | | |
| |||
0 commit comments