Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Sources/MCP/Client/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public actor Client {
// Start message handling loop
task = Task {
guard let connection = self.connection else { return }
repeat {
loop: while true {
// Check for cancellation before starting the iteration
if Task.isCancelled { break }

Expand Down Expand Up @@ -207,6 +207,8 @@ public actor Client {
)
}
}
await logger?.debug("Client receive stream finished; exiting loop.")
break loop
} catch let error where MCPError.isResourceTemporarilyUnavailable(error) {
try? await Task.sleep(for: .milliseconds(10))
continue
Expand All @@ -215,7 +217,7 @@ public actor Client {
"Error in message handling loop", metadata: ["error": "\(error)"])
break
}
} while true
}
await self.logger?.debug("Client message handling loop task is terminating.")
}

Expand Down