From e52ee8e2f479c0a4a67609d88599211a84e3f216 Mon Sep 17 00:00:00 2001 From: JajaComp Date: Tue, 6 May 2025 01:12:16 +0300 Subject: [PATCH] fix issue 2092 Issue: https://github.com/ExpediaGroup/graphql-kotlin/issues/2092 --- .../server/execution/subscription/GraphQLWebSocketServer.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/servers/graphql-kotlin-server/src/main/kotlin/com/expediagroup/graphql/server/execution/subscription/GraphQLWebSocketServer.kt b/servers/graphql-kotlin-server/src/main/kotlin/com/expediagroup/graphql/server/execution/subscription/GraphQLWebSocketServer.kt index 495aa0bc4f..d8ea5c30b5 100644 --- a/servers/graphql-kotlin-server/src/main/kotlin/com/expediagroup/graphql/server/execution/subscription/GraphQLWebSocketServer.kt +++ b/servers/graphql-kotlin-server/src/main/kotlin/com/expediagroup/graphql/server/execution/subscription/GraphQLWebSocketServer.kt @@ -36,6 +36,7 @@ import graphql.GraphQLContext import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.Job +import kotlinx.coroutines.job import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.delay @@ -82,6 +83,10 @@ abstract class GraphQLWebSocketServer( closeSession(session, GraphQLSubscriptionStatus.CONNECTION_INIT_TIMEOUT) } } + + (session as? CoroutineScope)?.coroutineContext?.job?.invokeOnCompletion { + subscriptions.values.forEach(Job::cancel) + } requestParser.parseRequestFlow(session) .map { objectMapper.readValue(it) }