Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix configure await #370

Merged
merged 3 commits into from
Nov 9, 2021
Merged

Fix configure await #370

merged 3 commits into from
Nov 9, 2021

Conversation

rose-a
Copy link
Collaborator

@rose-a rose-a commented Nov 1, 2021

Related to #161, #337, #332

  • Use .ConfigureAwait(false) on all awaits in library code
  • Use updated FluentAssertions.Reactive for testing observables
  • Remove "caching" of GraphQL subscriptions to fix test case CanReconnectWithSameObservable

Those overall changes seem to have considerably stabilized the unit tests, at least they run consistently across my dev machine and GitHub actions.

@sungam3r I'd like a second opinion on the changes regarding the CanReconnectWithSameObservable test case, I'll try to elaborate a bit on how the behaviour of the GraphQL client has changed through this (relevant changes in cff7f5f):

The test uses the Chat schema adopted from the server project (with some modifications), which uses a ReplaySubject<1> for it's message stream. The intentional design of this is that on subscribing to this stream the last message is played back on the client.

Up to now this library has created a hot observable for each subscription, cached it inside GraphQLHttpClient and returned the already created observable instance for repeated subscriptions with an equal request object. This caused the
aforementioned test case to fail on this line, where the second subscription expects to receive the replayed last chat message. But since the underlying GraphQL subscription did not terminate here but instead was reused, the server did not even notice that the subscription was disposed on the client side (don't ask me how this test has passed sometimes in the past 🙈 ).

Now the client does not try to reuse subscriptions any more and passes .Subscribe() and .Dispose() transparenty to the server. This includes creating two identical simultaneous subscriptions, which would then send the same data twice over the websocket connection.

IMO the old behaviour introduced incomprehensible behaviour, which is much worse than sending data twice, which can and should be prevented by the client application code.

I'd appreciate your feedback.

@sungam3r
Copy link
Member

sungam3r commented Jan 7, 2022

Sorry but I don't use subscriptions.

@rose-a rose-a deleted the fix-configure-await branch July 19, 2022 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants