Commit 54779aa
Add Task.Delay as GC root in ConnectAsync WhenAny
The async chain from ConnectAsync through initializeTask/processingTask
can become GC-unreachable on .NET 10/Ubuntu when the server process exits
before responding. The CancelAfter timer roots the chain through
CancellationToken registrations, but this path appears unreliable.
Task.Delay creates a System.Threading.Timer that is directly rooted in
the runtime's timer queue, providing a simple GC root chain:
Timer Queue -> Timer -> Task.Delay -> WhenAny -> ConnectAsync.
This ensures ConnectAsync always resumes within the initialization
timeout, even if intermediate state machines are collected.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 976f26c commit 54779aa
1 file changed
Lines changed: 21 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | | - | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
565 | 568 | | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
566 | 572 | | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
567 | 581 | | |
568 | 582 | | |
569 | 583 | | |
| |||
0 commit comments