Commit 3686f6f
Fix SendRequestAsync hang when background SSE stream delivers response before foreground transport send completes
Replace `await SendToRelatedTransportAsync(request, cancellationToken)` with
`Task.WhenAny(sendTask, tcs.Task)` so that if the response TCS completes
first (via a concurrent background channel such as the background GET SSE
stream in Streamable HTTP), execution proceeds immediately without waiting
for the foreground send. If the send completes first (normal case), it is
awaited directly, preserving the original behavior. The still-running send
task's exceptions are observed via a fire-and-forget ContinueWith(OnlyOnFaulted)
to prevent unobserved task exceptions.
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>1 parent 1d25d9b commit 3686f6f
1 file changed
+20
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
536 | 536 | | |
537 | 537 | | |
538 | 538 | | |
539 | | - | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
540 | 559 | | |
541 | 560 | | |
542 | 561 | | |
| |||
0 commit comments