Open vsfeedback opened 15 hours ago
Exceptions are not exposed to the user by default to avoid leaking information. https://learn.microsoft.com/aspnet/core/signalr/security?view=aspnetcore-8.0#exceptions
If you are explicitly throwing an error that you are ok with the client seeing, then you can throw a HubException
.
https://learn.microsoft.com/aspnet/core/signalr/hubs?view=aspnetcore-8.0#handle-errors
This issue has been moved from a ticket on Developer Community.
[severity:I'm unable to use this version] Issue Summary:
I have a SignalR server project which implements the Create method from the Microsoft.AspNet.SignalR.IHubActivator interface.
If an exception occurs in this Create method, I do not receive the corresponding exception on the client side. In other cases, when exceptions occur on the server side, they are propagated to the client so I can handle them appropriately, but not in this case.
Here is a simple chat application which demonstrates the issue: SignalRSelfHost.zip
This is based on the SignalR Self-Host tutorial here.
In the server portion of the application (SignalRSelfHost.csproj) I throw an exception in my IHubActivator implementation as shown below:
In the client project (JavascriptClient) I have an error handler which should be called whenever an error occurs when calling the only method on the SignalR hub, as shown below:
But when I run the project, no exception appears in the console window of the browser.
Questions:
Is there any way I can ensure that the client receives exceptions that are thrown in the IHubActivator.Create method?
If I am unable to propagate exceptions from the IHubActivator.Create method, my backup plan is to just return null whenever an exception occurs in IHubActivator.Create, since this does produce an exception on the client side. This way I can just output a generic message such as "Error occurred when creating SignalR Hub". Would you see any issue with handling IHubActivator.Create exceptions in this way?
Reproduction Steps:
Perform the following steps to reproduce the issue:
Original Comments
Feedback Bot on 10/28/2024, 06:37 PM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.