File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Sources/MCP/Base/Transports Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,11 @@ import struct Foundation.Data
168
168
while isConnected && !Task. isCancelled {
169
169
do {
170
170
let newData = try await receiveData ( )
171
+ // Check for EOF (empty data)
172
+ if newData. isEmpty {
173
+ logger. info ( " Connection closed by peer (EOF). " )
174
+ break // Exit loop gracefully
175
+ }
171
176
buffer. append ( newData)
172
177
173
178
// Process complete messages
@@ -219,8 +224,8 @@ import struct Foundation.Data
219
224
} else if let content = content {
220
225
continuation. resume ( returning: content)
221
226
} else {
222
- continuation . resume (
223
- throwing : MCPError . internalError ( " No data received " ) )
227
+ // EOF: Resume with empty data instead of throwing an error
228
+ continuation . resume ( returning : Data ( ) )
224
229
}
225
230
}
226
231
}
You can’t perform that action at this time.
0 commit comments