Skip to content

Respect CancellationToken in HubConnection.StartAsync() #10140

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

Conversation

danielloczi
Copy link
Contributor

Summary of the changes:
HubConnection.StartAsync() can be cancelled now even after network operations have started. CancellationToken passed through to HttpConnection and transports (LongPolling, ServerSentEvents, WebSocket).

Addresses #10059

If possible, please don't squash the commits of the PR so that both our names remain in the commit history :)

danielloczi and others added 4 commits May 10, 2019 10:15
… to network operations: both to NegotiateAsync(), and to StartTransport(). ITransport.StartAsync() modified to accept a CancellationToken.
@dnfclas
Copy link

dnfclas commented May 10, 2019

CLA assistant check
All CLA requirements met.

@davidfowl
Copy link
Member

@danielloczi Can you:

  • Remove all of the CancellationToken.None from all of the tests where it was added
  • use the new C# syntax = default instead of default(CancellationToken)

@danielloczi
Copy link
Contributor Author

Yes, will be there within a few mins!

…ing CancellationToken.None was removed from unit tests of all 3 transports (files were reverted to their original state), and the change was followed up in TestTransport.cs and EndToEndTests.cs.
@analogrelay analogrelay added the area-signalr Includes: SignalR clients and servers label May 10, 2019
@analogrelay analogrelay added this to the 3.0.0-preview6 milestone May 10, 2019
@BalintFarkas
Copy link
Contributor

@davidfowl CancellationToken.None was removed from all unit tests (they were reverted to their original versions). We're using the "Cancellation cancellationToken = default" syntax in ITransport.StartAsync() and all locations where this interface is implemented (the 3 transports and the 2 test files).

@analogrelay
Copy link
Contributor

If possible, please don't squash the commits of the PR so that both our names remain in the commit history

Yep, we generally try to merge commit external PRs. We ❤️ having external contributors in the commit history! (Reminder to @BrennanConroy and @halter73 who will probably be merging this ;P)

@danielloczi
Copy link
Contributor Author

Is there anything we can do to fix that failing test?
(to be honest, can't find the reason why it throws error: "System.ComponentModel.Win32Exception : The credentials supplied to the package were not recognized")

@analogrelay
Copy link
Contributor

analogrelay commented May 10, 2019

It's not related to the change :). We have some flaky tests and you just got hit with them. I'll handle it and restart the pipeline.

@analogrelay
Copy link
Contributor

@aspnet-hello
Copy link

This comment was made automatically. If there is a problem contact [email protected].

I've triaged the above build. I've created/commented on the following issue(s)
https://github.com/aspnet/AspNetCore-Internal/issues/1950

@analogrelay
Copy link
Contributor

@aspnet-hello
Copy link

This comment was made automatically. If there is a problem contact [email protected].

I've triaged the above build. I've created/commented on the following issue(s)
https://github.com/aspnet/AspNetCore-Internal/issues/2502

@halter73
Copy link
Member

@danielloczi I think we can merge this after #10140 (comment) is addressed.

… token param of StartAsync(). StopAsync() now can short circuit the start/reconnect attempt faster.
…gether by StartAsyncInner(). StartAsyncCore() and HandshakeAsync() methods not linking stopCts again.
Copy link
Member

@halter73 halter73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great aside from the two nits.

@halter73
Copy link
Member

Here's an issue to track adding tests: #10432

@halter73 halter73 changed the title Vibe/hubconnection startasync respect cancellationtoken netcore30 Respect CancellationToken in HubConnection.StartAsync() May 22, 2019
@halter73 halter73 merged commit dbe9ab7 into dotnet:master May 22, 2019
@halter73
Copy link
Member

Thanks @danielloczi!

@danielloczi
Copy link
Contributor Author

It was a team work together with @BalintFarkas! Thanks!

@BalintFarkas
Copy link
Contributor

BalintFarkas commented May 23, 2019

@anurse @halter73 If I see correctly, our commits were squashed after all, so I was removed from the list of authors :( Is there some way to add them un-squashed, or somehow add me as author, too? Just for the sweet glory :) Thanks!!

Edit: alternatively, I'd love to help out by creating the unit tests for this scenario, as tracked in this issue: #10432, and get the coveted contributorship that way. Would that be fine?

@analogrelay
Copy link
Contributor

Sorry about that @BalintFarkas . We generally merge external contributions but it looked like this got squashed. I don't think it's really possible to unsquash...

alternatively, I'd love to help out by creating the unit tests for this scenario, as tracked in this issue: #10432, and get the coveted contributorship that way

That would certainly be OK!

@halter73
Copy link
Member

Sorry @BalintFarkas! Totally my fault. I'll try not to let it happen it again.

@BalintFarkas
Copy link
Contributor

No problem - I'll get to work on the unit tests! :)

@github-actions github-actions bot locked and limited conversation to collaborators Dec 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-signalr Includes: SignalR clients and servers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants