Fix the difference in error handling between Kotlin and Typescript implementations in onClose (#31)

Makes the error handling behavior consistent between Kotlin and TypeScript
implementations when handling connection closure events.
This commit is contained in:
Sergey Ignatov 2024-12-23 09:03:35 +01:00 • committed by GitHub
commit 9931b1e666
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -191,15 +191,15 @@ public abstract class Protocol<SendRequestT : Request, SendNotificationT : Notif
}
private fun onClose() {
val error = McpError(ErrorCode.Defined.ConnectionClosed.code, "Connection closed")
for (handler in responseHandlers.values) {
handler(null, error)
}
responseHandlers.clear()
progressHandlers.clear()
transport = null
onclose()
val error = McpError(ErrorCode.Defined.ConnectionClosed.code, "Connection closed")
for (handler in responseHandlers.values) {
handler(null, error)
}
}
private fun onError(error: Throwable) {