Commit 254e1b0
committed
fix: send notifications/cancelled on request timeout and cancellation
Fixes #2507. BaseSession.send_request() never emits a
notifications/cancelled message when its in-flight await is interrupted,
whether by the SDK's own timeout or by external cancellation. The server
never learns the request was abandoned, leaving coroutines suspended
holding resources until the session ends.
Add a _send_cancelled_notification helper that does best-effort delivery,
and call it from both the TimeoutError and CancelledError handlers. The
cancellation path uses anyio.CancelScope(shield=True) to ensure the
notification is sent even during teardown.1 parent 3d7b311 commit 254e1b0
1 file changed
Lines changed: 25 additions & 0 deletions
File tree
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
292 | 293 | | |
293 | 294 | | |
294 | 295 | | |
| 296 | + | |
295 | 297 | | |
296 | 298 | | |
297 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
298 | 304 | | |
299 | 305 | | |
300 | 306 | | |
| |||
325 | 331 | | |
326 | 332 | | |
327 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
328 | 353 | | |
329 | 354 | | |
330 | 355 | | |
| |||
0 commit comments