Skip to content

Commit

Permalink
Waiting when disposing till the stop message was sent (#635)
Browse files Browse the repository at this point in the history
Co-authored-by: kim <kim.bechtold@webfactory-i4.de>
  • Loading branch information
kimlukas and kim authored Apr 22, 2024
1 parent 6d1c010 commit 6681418
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public IObservable<GraphQLResponse<TResponse>> CreateSubscriptionObservable<TRes

var disposable = new CompositeDisposable(
observable.Subscribe(observer),
Disposable.Create(async () =>
Disposable.Create(() =>
{
Debug.WriteLine($"disposing subscription {startRequest.Id}, websocket state is '{_webSocketHandler.WebSocketState}'");
// only try to send close request on open websocket
Expand All @@ -126,7 +126,7 @@ public IObservable<GraphQLResponse<TResponse>> CreateSubscriptionObservable<TRes
try
{
Debug.WriteLine($"sending stop message on subscription {startRequest.Id}");
await _queueWebSocketRequest(stopRequest).ConfigureAwait(false);
_queueWebSocketRequest(stopRequest).GetAwaiter().GetResult();
}
// do not break on disposing
catch (OperationCanceledException) { }
Expand Down
4 changes: 2 additions & 2 deletions src/GraphQL.Client/Websocket/GraphQLWSProtocolHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public IObservable<GraphQLResponse<TResponse>> CreateSubscriptionObservable<TRes

var disposable = new CompositeDisposable(
observable.Subscribe(observer),
Disposable.Create(async () =>
Disposable.Create(() =>
{
Debug.WriteLine($"disposing subscription {startRequest.Id}, websocket state is '{_webSocketHandler.WebSocketState}'");
// only try to send close request on open websocket
Expand All @@ -111,7 +111,7 @@ public IObservable<GraphQLResponse<TResponse>> CreateSubscriptionObservable<TRes
try
{
Debug.WriteLine($"sending stop message on subscription {startRequest.Id}");
await _queueWebSocketRequest(stopRequest).ConfigureAwait(false);
_queueWebSocketRequest(stopRequest).GetAwaiter().GetResult();
}
// do not break on disposing
catch (OperationCanceledException) { }
Expand Down

0 comments on commit 6681418

Please sign in to comment.