Skip to content

Conversation

@BrennanConroy
Copy link
Member

Fixing an instance of unobserved tasks that was causing clients in UWP apps to crash.
Not sure if this 100% fixes #12193 as one of the stack traces showed HubConnection.ReceiveLoop causing a crash (which looks impossible IMO).

@BrennanConroy BrennanConroy added the area-signalr Includes: SignalR clients and servers label Jul 18, 2019
@BrennanConroy BrennanConroy requested a review from davidfowl July 18, 2019 16:50

// We re-throw here so we can communicate that there was an error when sending
// the close frame
throw;
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the main culprit for unobserved tasks.

An alternative solution would be to keep this and actually observe the exception and set a private field to let the send loop know to send an internal server error instead of possibly a normal exit code.
https://github.com/aspnet/AspNetCore/blob/010ffe612150d9a3f5b78f2ad3ffcee3aedef369/src/SignalR/common/Http.Connections/src/Internal/Transports/WebSocketsTransport.cs#L272

@analogrelay analogrelay added this to the 3.0.0-preview8 milestone Jul 18, 2019
@BrennanConroy
Copy link
Member Author

@BrennanConroy
Copy link
Member Author

@aspnet-hello
Copy link

This comment was made automatically. If there is a problem contact aspnetcore-build@microsoft.com.

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

@aspnet-hello
Copy link

This comment was made automatically. If there is a problem contact aspnetcore-build@microsoft.com.

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

if (trigger == receiving)
{
// Observe exception if there is one to avoid unobserved tasks
_ = receiving.Exception;
Copy link
Member

Choose a reason for hiding this comment

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

Why don't these exceptions matter? Should we at least be logging them?

Copy link
Contributor

Choose a reason for hiding this comment

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

We probably should, but to no higher than Debug since they will include client disconnects.

Copy link
Member

Choose a reason for hiding this comment

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

Debug ftw

Copy link
Member Author

Choose a reason for hiding this comment

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

These should never actually have exceptions in them, I was just being paranoid. We have a try catch around both sending and receiving so the only exceptions that could escape would be Pipe.Complete throwing, logger throwing, or socket.CloseOutputAsync (this would be the one most likely to throw).

I'll just wrap socket.CloseOutputAsync and log it if it throws.

Copy link
Member

Choose a reason for hiding this comment

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

Can we get rid of all the _ = blah.Exception lines then?

The mere existence of these lines communicates to other developers that these tasks could have completed with an exception. I don't want to risk seeing this pattern copied more widely. The more places this pattern is used, the more likely it will be copied somewhere else.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I'm good with removing them

Copy link
Member

Choose a reason for hiding this comment

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

Cool. If for whatever reason we are still concerned about something unexpected throwing, we could also replace the _ = blah.Exception with await trigger. That way if there was an unexpected error, WebSocketTransport.StopAsync() would rethrow it.

@analogrelay analogrelay added the tell-mode Indicates a PR which is being merged during tell-mode label Jul 23, 2019
@BrennanConroy
Copy link
Member Author

🆙 📅

@BrennanConroy
Copy link
Member Author

@aspnet-hello
Copy link

This comment was made automatically. If there is a problem contact aspnetcore-build@microsoft.com.

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

@BrennanConroy BrennanConroy merged commit 648bdf7 into master Jul 25, 2019
@ghost ghost deleted the brecon/unobserved branch July 25, 2019 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-signalr Includes: SignalR clients and servers tell-mode Indicates a PR which is being merged during tell-mode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SignalR Client sometimes crashing UWP app

6 participants