Skip to content

Commit 573365e

Browse files
committed
Remove more await logger calls that block Task execution
Removed await logger?.debug() calls in the Task before the for-await loop to prevent actor boundary crossing delays that could cause the loop to miss yielded data.
1 parent 469a2e6 commit 573365e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Sources/MCP/Client/Client.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,15 @@ public actor Client {
195195

196196
// Get stream once - don't call receive() repeatedly
197197
NSLog("🔵 CLIENT: Getting stream from connection.receive()")
198-
await logger?.debug("CLIENT: Getting stream from connection.receive()")
198+
// REMOVED: await logger?.debug() - causes actor boundary delay
199199
let stream = await connection.receive()
200200
NSLog("🔵 CLIENT: Got stream, starting for-await loop")
201-
await logger?.debug("CLIENT: Got stream, starting for-await loop")
201+
// REMOVED: await logger?.debug() - causes actor boundary delay
202202

203203
do {
204204
for try await data in stream {
205205
NSLog("🔵 CLIENT: Received data in loop - \(data.count) bytes")
206+
// Keep this one - it's after we receive data so no race condition
206207
await logger?.debug("CLIENT: Received data in loop", metadata: ["size": "\(data.count)"])
207208
if Task.isCancelled { break }
208209

0 commit comments

Comments
 (0)