Commit 40aa45c
committed
Fix ObjectDisposedException when disposing session after client.StopAsync()
Make CopilotSession.DisposeAsync() idempotent and tolerant to already-disposed
connections. This fixes the crash when 'await using var session' cleanup runs
after client.StopAsync() has already disposed the connection.
Changes:
- Add _isDisposed flag with Interlocked.Exchange for thread-safe idempotency
- Catch ObjectDisposedException and IOException during dispose (connection gone)
- Add regression test to ClientTests
Fixes #3061 parent 73c1431 commit 40aa45c
2 files changed
+28
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
553 | 554 | | |
554 | 555 | | |
555 | 556 | | |
556 | | - | |
557 | | - | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
558 | 575 | | |
559 | 576 | | |
560 | 577 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
246 | 255 | | |
0 commit comments