Skip to content

Commit 311d638

Browse files
committed
Fix the difference in error handling between Kotlin and Typescript implementations in onClose
Makes the error handling behavior consistent between Kotlin and TypeScript implementations when handling connection closure events.
1 parent d8a8f89 commit 311d638

File tree

1 file changed

+5
-5
lines changed
  • src/main/kotlin/io/modelcontextprotocol/kotlin/sdk/shared

1 file changed

+5
-5
lines changed

src/main/kotlin/io/modelcontextprotocol/kotlin/sdk/shared/Protocol.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,15 @@ public abstract class Protocol<SendRequestT : Request, SendNotificationT : Notif
191191
}
192192

193193
private fun onClose() {
194-
val error = McpError(ErrorCode.Defined.ConnectionClosed.code, "Connection closed")
195-
for (handler in responseHandlers.values) {
196-
handler(null, error)
197-
}
198-
199194
responseHandlers.clear()
200195
progressHandlers.clear()
201196
transport = null
202197
onclose()
198+
199+
val error = McpError(ErrorCode.Defined.ConnectionClosed.code, "Connection closed")
200+
for (handler in responseHandlers.values) {
201+
handler(null, error)
202+
}
203203
}
204204

205205
private fun onError(error: Throwable) {

0 commit comments

Comments
 (0)