Skip to content

Commit

Permalink
Cleanup gql subscription session state correctly (#859)
Browse files Browse the repository at this point in the history
In case a socket got disconnected, the session state of the subscriptions did not get correctly cleaned up.
The active operations did get closed but not removed and thus, when the client tried to reconnect, the server incorrectly detected an active subscription for an operation and immediately terminated the subscription.
  • Loading branch information
schroda authored Feb 2, 2024
1 parent dc124fb commit 8aa75be
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class ApolloSubscriptionProtocolHandler(
}

private fun onDisconnect(context: WsContext): Flow<SubscriptionOperationMessage> {
logger.debug("Session \"${context.sessionId}\" disconnected")
sessionState.terminateSession(context, CloseStatus(1000, "Normal Closure"))
return emptyFlow()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ internal class ApolloSubscriptionSessionState {
code: CloseStatus,
) {
sessionToOperationId.remove(context.sessionId)?.forEach {
activeOperations[it]?.cancel()
removeActiveOperation(it)
}
cachedGraphQLContext.remove(context.sessionId)
context.closeSession(code)
Expand Down

0 comments on commit 8aa75be

Please sign in to comment.