Commit 08afa6a
fix(session): drop unknown-ID responses instead of crashing session
When a response arrives for a request ID that has no pending waiter
(e.g. the request timed out and was removed from _response_streams),
the previous code called _handle_incoming(RuntimeError(...)), which
routed through _default_message_handler, which now re-raises on any
Exception — killing the session and sending CONNECTION_CLOSED to all
remaining in-flight requests.
The unknown-ID case is non-fatal: the late response simply has nowhere
to go. Log a warning and drop it; don't propagate through the message
handler. This matches the intention of the existing warning log in
_normalize_request_id and keeps the session alive for subsequent work.
Also updated the #1401 test module docstring to clarify that
protocol-level non-fatal errors are handled inline, not via
_default_message_handler.
Fixes regressions in:
- test_notification_validation_error (test_88_random_error.py)
- test_response_id_non_numeric_string_no_match (test_session.py)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent cb53075 commit 08afa6a
2 files changed
Lines changed: 9 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
516 | 516 | | |
517 | 517 | | |
518 | 518 | | |
519 | | - | |
| 519 | + | |
520 | 520 | | |
521 | 521 | | |
522 | 522 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
11 | 16 | | |
12 | 17 | | |
13 | 18 | | |
| |||
0 commit comments