diff --git a/src/SignalR/server/Core/src/Internal/DefaultHubDispatcher.cs b/src/SignalR/server/Core/src/Internal/DefaultHubDispatcher.cs index 16f1b8da63..9f7d6ffe56 100644 --- a/src/SignalR/server/Core/src/Internal/DefaultHubDispatcher.cs +++ b/src/SignalR/server/Core/src/Internal/DefaultHubDispatcher.cs @@ -331,6 +331,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal } 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)); return; diff --git a/src/SignalR/server/SignalR/test/HubConnectionHandlerTests.cs b/src/SignalR/server/SignalR/test/HubConnectionHandlerTests.cs index d78cf6f668..25e47f03f4 100644 --- a/src/SignalR/server/SignalR/test/HubConnectionHandlerTests.cs +++ b/src/SignalR/server/SignalR/test/HubConnectionHandlerTests.cs @@ -859,10 +859,17 @@ namespace Microsoft.AspNetCore.SignalR.Tests [InlineData(nameof(MethodHub.MethodThatYieldsFailedTask), false)] public async Task HubMethodCanThrowOrYieldFailedTask(string methodName, bool detailedErrors) { + var hasErrorLog = false; bool ExpectedErrors(WriteContext writeContext) { - return writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" && + var expected = writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" && writeContext.EventId.Name == "FailedInvokingHubMethod"; + if (expected) + { + hasErrorLog = true; + return true; + } + return false; } using (StartVerifiableLog(ExpectedErrors)) @@ -898,6 +905,8 @@ namespace Microsoft.AspNetCore.SignalR.Tests await connectionHandlerTask.OrTimeout(); } } + + Assert.True(hasErrorLog); } [Fact]