Repository navigation
Commit f72f202
fix: do not re-stringify a failed exception when building an internal error
The internal-error recovery in `Connection._execute_request` guarded
`json.loads(str(exc))` with a `try`, then called `str(exc)` a second time
inside that `except` clause. An exception whose `__str__` raises therefore
made the recovery path re-run the call that had just failed, where no
sibling handler could catch it: the error propagated out of
`_execute_request`, `_run_request` re-raised at `handler.result()`, and no
reply was ever written. The peer waits on that request id forever.
Any exception whose `__str__` depends on state that is gone reaches this —
a lazy proxy, a closed cursor, a partially-initialised object.
Stringify once, before either branch, and fall back to
`f"<unprintable {type(exc).__name__}>"`, which reads the class attribute and
calls nothing on the instance. `repr(exc)` would be the same hazard again.
An exception whose message is valid JSON still takes the `json.loads`
branch; a test pins that.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 9853d8b commit f72f202
2 files changed
Lines changed: 64 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
281 | 284 | | |
282 | | - | |
| 285 | + | |
283 | 286 | | |
284 | | - | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
285 | 294 | | |
286 | 295 | | |
287 | 296 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
975 | 975 | | |
976 | 976 | | |
977 | 977 | | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
0 commit comments