Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import io.modelcontextprotocol.kotlin.sdk.server.mcpWebSocket
import io.modelcontextprotocol.kotlin.sdk.server.mcpWebSocketTransport
import io.modelcontextprotocol.kotlin.sdk.shared.BaseTransportTest
import kotlinx.coroutines.CompletableDeferred
import kotlin.test.Ignore
import kotlin.test.Test
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Timeout
import java.util.concurrent.TimeUnit

@Timeout(30, unit = TimeUnit.SECONDS)
class WebSocketTransportTest : BaseTransportTest() {
@Test
@Ignore // "Test disabled for investigation #17"
fun `should start then close cleanly`() = testApplication {
install(WebSockets)
routing {
Expand All @@ -26,7 +27,6 @@ class WebSocketTransportTest : BaseTransportTest() {
}

@Test
@Ignore // "Test disabled for investigation #17"
fun `should read messages`() = testApplication {
val clientFinished = CompletableDeferred<Unit>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import io.ktor.websocket.close
import io.ktor.websocket.readText
import io.modelcontextprotocol.kotlin.sdk.types.JSONRPCMessage
import io.modelcontextprotocol.kotlin.sdk.types.McpJson
import kotlinx.coroutines.CancellationException
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file now imports both kotlinx.coroutines.CancellationException and kotlin.coroutines.cancellation.CancellationException, which will either be ambiguous at compile time or lead to inconsistent type checks (e.g., the catch (e: CancellationException) and it !is CancellationException checks). Remove one import and consistently use the project-standard kotlin.coroutines.cancellation.CancellationException (as used in other core transport code).

Suggested change
import kotlinx.coroutines.CancellationException

Copilot uses AI. Check for mistakes.
import kotlinx.coroutines.CoroutineName
Comment thread
devcrocod marked this conversation as resolved.
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.InternalCoroutinesApi
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.channels.ClosedReceiveChannelException
import kotlinx.coroutines.job
Expand Down Expand Up @@ -81,9 +81,8 @@ public abstract class WebSocketMcpTransport : AbstractTransport() {
}
}

@OptIn(InternalCoroutinesApi::class)
session.coroutineContext.job.invokeOnCompletion {
if (it != null) {
if (it != null && it !is CancellationException) {
Comment thread
devcrocod marked this conversation as resolved.
_onError.invoke(it)
} else {
invokeOnCloseCallback()
Expand Down
Loading