diff --git a/src/GraphQL.AspNetCore3/WebSockets/WebSocketConnection.cs b/src/GraphQL.AspNetCore3/WebSockets/WebSocketConnection.cs index 2885bbb..4b9e922 100644 --- a/src/GraphQL.AspNetCore3/WebSockets/WebSocketConnection.cs +++ b/src/GraphQL.AspNetCore3/WebSockets/WebSocketConnection.cs @@ -169,7 +169,9 @@ public Task CloseAsync(int eventId, string? description) /// public Task SendMessageAsync(OperationMessage message) { - _pump.Post(new Message { OperationMessage = message }); + // Messages posted after requesting the connection be closed will be discarded. + if (!_closeRequested) + _pump.Post(new Message { OperationMessage = message }); return Task.CompletedTask; }