Add missing log to hub method failure (#10903)

This commit is contained in:
Brennan 2019-06-05 20:17:40 -07:00 committed by GitHub
parent bc6f4b6034
commit c518cff370
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -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;

View File

@ -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]