Is there an existing issue for this?
Describe the bug
Depending of the order of the middlewares, when a request timeout occurs, a 499 status code (instead of 504) may be returned:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRequestTimeouts();
var app = builder.Build();
// If I put the RequestTimeoutsMiddleware here (before Exception Handler), I get a 499 error when a Timeout occurs.
app.UseRequestTimeouts();
app.UseExceptionHandler();
// If I put the RequestTimeoutsMiddleware here (after Exception Handler), I get (as expected) a 504 error when a Timeout occurs.
//app.UseRequestTimeouts();
I think this is caused by this code in the Exception Handler Middleware: https://github.com/dotnet/aspnetcore/blob/main/src/Middleware/Diagnostics/src/ExceptionHandler/ExceptionHandlerMiddlewareImpl.cs#L117-L128
Expected Behavior
When a request timeout occurs, I expected to always get the 504 error (or the one that has been configured in the policy).
Steps To Reproduce
Minimal repro here: https://github.com/marcominerva/TimeoutIssue
Exceptions (if any)
No response
.NET Version
8.0.100
Anything else?
No response
Is there an existing issue for this?
Describe the bug
Depending of the order of the middlewares, when a request timeout occurs, a 499 status code (instead of 504) may be returned:
I think this is caused by this code in the Exception Handler Middleware: https://github.com/dotnet/aspnetcore/blob/main/src/Middleware/Diagnostics/src/ExceptionHandler/ExceptionHandlerMiddlewareImpl.cs#L117-L128
Expected Behavior
When a request timeout occurs, I expected to always get the 504 error (or the one that has been configured in the policy).
Steps To Reproduce
Minimal repro here: https://github.com/marcominerva/TimeoutIssue
Exceptions (if any)
No response
.NET Version
8.0.100
Anything else?
No response