Skip to content

Commit

Permalink
Discard messages sent after the close message has been posted to the …
Browse files Browse the repository at this point in the history
…queue
  • Loading branch information
Shane32 committed Oct 27, 2024
1 parent cbd7a33 commit 02955ae
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/GraphQL.AspNetCore3/WebSockets/WebSocketConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ public Task CloseAsync(int eventId, string? description)
/// <inheritdoc/>
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;
}

Expand Down

0 comments on commit 02955ae

Please sign in to comment.