Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions src/SignalR/server/Core/src/Internal/DefaultHubDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,19 +334,30 @@ await SendInvocationError(hubMethodInvocationMessage.InvocationId, connection,
else
{
// Invoke or Send
async Task ExecuteInvocation()
static async Task ExecuteInvocation(DefaultHubDispatcher<THub> dispatcher,
ObjectMethodExecutor methodExecutor,
THub hub,
object?[] arguments,
IServiceScope scope,
IHubActivator<THub> hubActivator,
HubConnectionContext connection,
HubMethodInvocationMessage hubMethodInvocationMessage,
bool isStreamCall)
{
var logger = dispatcher._logger;
var enableDetailedErrors = dispatcher._enableDetailedErrors;

object? result;
try
{
result = await ExecuteHubMethod(methodExecutor, hub, arguments, connection, scope.ServiceProvider);
Log.SendingResult(_logger, hubMethodInvocationMessage.InvocationId, methodExecutor);
result = await dispatcher.ExecuteHubMethod(methodExecutor, hub, arguments, connection, scope.ServiceProvider);
Log.SendingResult(logger, hubMethodInvocationMessage.InvocationId, methodExecutor);
}
catch (Exception ex)
{
Log.FailedInvokingHubMethod(_logger, hubMethodInvocationMessage.Target, ex);
await SendInvocationError(hubMethodInvocationMessage.InvocationId, connection,
ErrorMessageHelper.BuildErrorMessage($"An unexpected error occurred invoking '{hubMethodInvocationMessage.Target}' on the server.", ex, _enableDetailedErrors));
Log.FailedInvokingHubMethod(logger, hubMethodInvocationMessage.Target, ex);
await dispatcher.SendInvocationError(hubMethodInvocationMessage.InvocationId, connection,
ErrorMessageHelper.BuildErrorMessage($"An unexpected error occurred invoking '{hubMethodInvocationMessage.Target}' on the server.", ex, enableDetailedErrors));
return;
}
finally
Expand All @@ -355,7 +366,7 @@ await SendInvocationError(hubMethodInvocationMessage.InvocationId, connection,
// And normal invocations handle cleanup below in the finally
if (isStreamCall)
{
await CleanupInvocation(connection, hubMethodInvocationMessage, hubActivator, hub, scope);
await dispatcher.CleanupInvocation(connection, hubMethodInvocationMessage, hubActivator, hub, scope);
}
}

Expand All @@ -366,7 +377,8 @@ await SendInvocationError(hubMethodInvocationMessage.InvocationId, connection,
await connection.WriteAsync(CompletionMessage.WithResult(hubMethodInvocationMessage.InvocationId, result));
}
}
invocation = ExecuteInvocation();

invocation = ExecuteInvocation(this, methodExecutor, hub, arguments, scope, hubActivator, connection, hubMethodInvocationMessage, isStreamCall);
}

if (isStreamCall || isStreamResponse)
Expand Down