Skip to content

Commit

Permalink
handle close failures
Browse files Browse the repository at this point in the history
  • Loading branch information
yaananth committed Mar 28, 2022
1 parent b3b97b7 commit 0eb4ee2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Runner.Common/JobServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,18 @@ public void InitializeWebsocketClient(ServiceEndpoint serviceEndpoint)

public ValueTask DisposeAsync()
{
_websocketClient?.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, "Shutdown", CancellationToken.None);
try
{
_websocketClient?.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, "Shutdown", CancellationToken.None);
}
catch (Exception ex)
{
// In some cases this might be okay since the websocket might be open yet, so just close and don't trace exceptions
Trace.Info($"Failed to close websocket gracefully {ex.GetType().Name}");
}

GC.SuppressFinalize(this);

return ValueTask.CompletedTask;
}

Expand Down

0 comments on commit 0eb4ee2

Please sign in to comment.