Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.94k stars 442 forks source link

Azure Functions (.NET8,Isolated) execution stalled and in limbo after uncaught exception #10489

Closed aaramians closed 2 days ago

aaramians commented 1 month ago

Core Tools Version: 4.0.6280 Commit hash: N/A +421f0144b42047aa289ce691dc6db4fc8b6143e6 (64-bit) Function Runtime Version: 4.834.3.22875 .NET 8 - Isolated

Steps: Start with brand new template project on Azure Function and throw an exception:

        [Function("Function1")]
        public IActionResult Run([HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequest req)
        {
            throw new InvalidOperationException();

            _logger.LogInformation("C# HTTP trigger function processed a request.");
            return new OkObjectResult("Welcome to Azure Functions!");
        }
curl http://localhost:7135/api/Function1

Expectation: The client stalls, the server also stalls I was expecting the client connection to be dropped and server/host to fail the invocation.

The issue I encountered was more complex. If the intended design is to prevent exceptions from bubbling up to the framework for handling, I can understand that this may be the expected behavior, where middleware would be responsible for catching the exception. This was the approach I attempted; however, I was unable to close the connection or mark the invocation as failed, while using function context/GetHttpContext/GetInvocationResult/...

On the other hand, if the framework is expected to handle this, I wouldn't anticipate a stall scenario.

bhagyshricompany commented 1 month ago

@aaramians thanks for reporting will update you.

bhagyshricompany commented 1 month ago

@kshyju pls confirm and validate.

satvu commented 1 week ago

@aaramians Does this still repro if you use the latest available package here: https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore?

microsoft-github-policy-service[bot] commented 5 days ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

If you are not the original author (aaramians) and believe this issue is not stale, please comment with /bot not-stale and I will not close it.