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 (#79)
  • Loading branch information
Shane32 authored Oct 27, 2024
1 parent cbd7a33 commit 39f8dd8
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 39f8dd8

Please sign in to comment.