Add missing log to hub method failure (#10903)
This commit is contained in:
parent
bc6f4b6034
commit
c518cff370
|
|
@ -331,6 +331,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Log.FailedInvokingHubMethod(_logger, hubMethodInvocationMessage.Target, ex);
|
||||||
await SendInvocationError(hubMethodInvocationMessage.InvocationId, connection,
|
await SendInvocationError(hubMethodInvocationMessage.InvocationId, connection,
|
||||||
ErrorMessageHelper.BuildErrorMessage($"An unexpected error occurred invoking '{hubMethodInvocationMessage.Target}' on the server.", ex, _enableDetailedErrors));
|
ErrorMessageHelper.BuildErrorMessage($"An unexpected error occurred invoking '{hubMethodInvocationMessage.Target}' on the server.", ex, _enableDetailedErrors));
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -859,10 +859,17 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
[InlineData(nameof(MethodHub.MethodThatYieldsFailedTask), false)]
|
[InlineData(nameof(MethodHub.MethodThatYieldsFailedTask), false)]
|
||||||
public async Task HubMethodCanThrowOrYieldFailedTask(string methodName, bool detailedErrors)
|
public async Task HubMethodCanThrowOrYieldFailedTask(string methodName, bool detailedErrors)
|
||||||
{
|
{
|
||||||
|
var hasErrorLog = false;
|
||||||
bool ExpectedErrors(WriteContext writeContext)
|
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";
|
writeContext.EventId.Name == "FailedInvokingHubMethod";
|
||||||
|
if (expected)
|
||||||
|
{
|
||||||
|
hasErrorLog = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (StartVerifiableLog(ExpectedErrors))
|
using (StartVerifiableLog(ExpectedErrors))
|
||||||
|
|
@ -898,6 +905,8 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
await connectionHandlerTask.OrTimeout();
|
await connectionHandlerTask.OrTimeout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Assert.True(hasErrorLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue