Skip to content

Remove application error #25882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 14, 2020
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/Servers/IIS/IIS/src/Core/IISHttpContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ protected async Task FireOnCompleted()
}
catch (Exception ex)
{
ReportApplicationError(ex);
Log.ApplicationError(_logger, ((IHttpConnectionFeature)this).ConnectionId, TraceIdentifier, ex);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,26 @@ public async Task EnvironmentVariableForLauncherArgsIsPreferred(HostingModel hos
await StartAsync(deploymentParameters);
}

[ConditionalFact]
[RequiresNewHandler]
[MaximumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10_20H1, SkipReason = "Shutdown hangs https://github.com/dotnet/aspnetcore/issues/25107")]
public async Task OnCompletedDoesNotFailRequest()
{
var deploymentParameters = Fixture.GetBaseDeploymentParameters();
var deploymentResult = await DeployAsync(deploymentParameters);

var response = await deploymentResult.HttpClient.GetAsync("/OnCompletedThrows");
Assert.True(response.IsSuccessStatusCode);

StopServer();

if (deploymentParameters.ServerType == ServerType.IISExpress)
{
// We can't read stdout logs from IIS as they aren't redirected.
Assert.Contains(TestSink.Writes, context => context.Message.Contains("An unhandled exception was thrown by the application."));
}
}

private static void VerifyDotnetRuntimeEventLog(IISDeploymentResult deploymentResult)
{
var entries = GetEventLogsFromDotnetRuntime(deploymentResult);
Expand Down
10 changes: 10 additions & 0 deletions src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,16 @@ public Task IncreaseRequestLimit(HttpContext httpContext)
return Task.CompletedTask;
}

public Task OnCompletedThrows(HttpContext httpContext)
{
httpContext.Response.OnCompleted(() =>
{
throw new Exception();
});

return Task.CompletedTask;
}

internal static readonly HashSet<(string, StringValues, StringValues)> NullTrailers = new HashSet<(string, StringValues, StringValues)>()
{
("NullString", (string)null, (string)null),
Expand Down