-
Notifications
You must be signed in to change notification settings - Fork 445
Conversation
{ | ||
get | ||
{ | ||
if (_bindingError != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How bad is this?
@@ -8,13 +8,29 @@ namespace Microsoft.AspNetCore.SignalR.Internal.Protocol | |||
{ | |||
public class InvocationMessage : HubMessage | |||
{ | |||
// Use ExceptionDispatchInfo ? | |||
private readonly Exception _bindingError; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes use ExceptionDispatchInfo
327d672
to
72d1f7a
Compare
Storing exception thrown during parameter binding and rethrowing when the method is about to throw. This allows completing invocations with a HubException and keeping the connection open. We will also no longer close the connection if parameters for client side methods cannot be bound. We will log and continue. Fixes: #818 (Also fixing #1005 because I was just touching this line)
72d1f7a
to
2e0d99f
Compare
Ready for review. |
@@ -137,7 +137,7 @@ public static void IssueInvocation(this ILogger logger, string invocationId, str | |||
{ | |||
if (logger.IsEnabled(LogLevel.Trace)) | |||
{ | |||
var argsList = string.Join(", ", args.Select(a => a.GetType().FullName)); | |||
var argsList = string.Join(", ", args.Select(a => a?.GetType().FullName?? "(null)")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space after FullName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add null check for args
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't do because it never happens but I think it won't hurt either.
|
||
// TODO(anurse): We can add some DI magic here to allow users to provide their own serialization | ||
// Related Bug: https://github.com/aspnet/SignalR/issues/261 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to keep this comment in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We allow setting serialization settings in HubOptions so this is covered (#261 is closed).
} | ||
catch (Exception ex) | ||
{ | ||
throw new FormatException("Error binding arguments. Make sure that types of the provided values match the types of the hub method being invoked.", ex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"that the types"
if (parameterTypes.Length != argumentCount) | ||
{ | ||
throw new FormatException( | ||
$"Target method expects {parameterTypes.Length} arguments(s) but invocation has {argumentCount} argument(s)."); | ||
$"Invocation provides {argumentCount} argument(s) but target expects {parameterTypes.Length}."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we log on the server for any binding failures?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - it now fails when we are invoking the method so it is treated as any other hub method invocation error
@@ -556,7 +556,7 @@ public class RedisExcludeClientsMessage : InvocationMessage | |||
public IReadOnlyList<string> ExcludedIds; | |||
|
|||
public RedisExcludeClientsMessage(string invocationId, bool nonBlocking, string target, IReadOnlyList<string> excludedIds, params object[] arguments) | |||
: base(invocationId, nonBlocking, target, arguments) | |||
: base(invocationId, nonBlocking, target, null, arguments) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't hurt to use named params here
test/Common/TestClient.cs
Outdated
@@ -136,7 +136,7 @@ public Task<string> SendInvocationAsync(string methodName, params object[] args) | |||
public Task<string> SendInvocationAsync(string methodName, bool nonBlocking, params object[] args) | |||
{ | |||
var invocationId = GetInvocationId(); | |||
return SendHubMessageAsync(new InvocationMessage(invocationId, nonBlocking, methodName, args)); | |||
return SendHubMessageAsync(new InvocationMessage(invocationId, nonBlocking, methodName, null, args)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
named param
Soliciting early feedback.