From 31f8fe2d20ed639a5b324ffce115ad070ee24a99 Mon Sep 17 00:00:00 2001 From: Daniel Weber Date: Thu, 21 Mar 2024 10:32:50 +0100 Subject: [PATCH] Fail WebSocket early. --- .../Factory/WebSocketGremlinqClientFactory.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Providers.Core/Factory/WebSocketGremlinqClientFactory.cs b/src/Providers.Core/Factory/WebSocketGremlinqClientFactory.cs index 1d4e12086d..cd15c41358 100644 --- a/src/Providers.Core/Factory/WebSocketGremlinqClientFactory.cs +++ b/src/Providers.Core/Factory/WebSocketGremlinqClientFactory.cs @@ -227,6 +227,9 @@ public IAsyncEnumerable> SubmitAsync(RequestMessage messag static async IAsyncEnumerable> Core(RequestMessage message, WebSocketGremlinqClient @this, [EnumeratorCancellation] CancellationToken ct = default) { + if (@this._client.CloseStatus is not null) + throw new ObjectDisposedException(nameof(WebSocketGremlinqClient)); + using (var channel = new Channel(@this)) { using (var linkedCts = CancellationTokenSource.CreateLinkedTokenSource(ct, @this._cts.Token)) @@ -307,9 +310,9 @@ private async Task SendCore(RequestMessage requestMessage, CancellationToken ct) { using (buffer) { - await _client.SendAsync(buffer.Memory, WebSocketMessageType.Binary, true, ct); - } - } + await _client.SendAsync(buffer.Memory, WebSocketMessageType.Binary, true, ct); + } + } else throw new InvalidOperationException(); }