From c518cff370849622d335fe7a35b944b87b65e696 Mon Sep 17 00:00:00 2001 From: Brennan Date: Wed, 5 Jun 2019 20:17:40 -0700 Subject: [PATCH] Add missing log to hub method failure (#10903) --- .../server/Core/src/Internal/DefaultHubDispatcher.cs | 1 + .../server/SignalR/test/HubConnectionHandlerTests.cs | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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]