File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ actor ConnectionHealthMonitor {
9292
9393 Self . logger. trace ( " Starting health monitoring for connection \( self . connectionId) " )
9494
95- let ( wakeUpStream, continuation) = AsyncStream< Void> . makeStream( )
95+ let ( wakeUpStream, continuation) = AsyncStream< Void> . makeStream( bufferingPolicy : . bufferingNewest ( 1 ) )
9696 self . wakeUpContinuation = continuation
9797
9898 monitoringTask = Task { [ weak self] in
@@ -107,6 +107,8 @@ actor ConnectionHealthMonitor {
107107 var wakeIterator = wakeUpStream. makeAsyncIterator ( )
108108
109109 while !Task. isCancelled {
110+ await Task . yield ( )
111+
110112 // Race between the normal ping interval and an early wake-up signal
111113 await withTaskGroup ( of: Bool . self) { group in
112114 group. addTask {
@@ -141,10 +143,10 @@ actor ConnectionHealthMonitor {
141143 Self . logger. trace ( " Stopping health monitoring for connection \( self . connectionId) " )
142144 let task = monitoringTask
143145 monitoringTask = nil
144- wakeUpContinuation? . finish ( )
145- wakeUpContinuation = nil
146146 task? . cancel ( )
147147 await task? . value
148+ wakeUpContinuation? . finish ( )
149+ wakeUpContinuation = nil
148150 }
149151
150152 /// Triggers an immediate health check, interrupting the normal 30-second sleep.
You can’t perform that action at this time.
0 commit comments