Azure / Azure/azure-functions-host
Returning a disposed HttpResponseMessage takes over 2 minutes
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 38
Description
The customer from ICM Incident 232358774 noticed that if a function receives a disposed `HttpResponseMessage` to return, then the function won't return a 502 Bad Gateway immediately, but will instead take over 120 seconds before returning a 502 Bad Gateway response.
This behavior is only observed in Azure and not in local development.
#### Investigative information
Please provide the following:
- Timestamp: 2021-04-27 00:11:59.886
- Function App version: 3.0
- Function App name: vabachuhttpdisposebug
- Function name(s) (as appropriate): HttpTrigger
- Invocation ID: f35c0d00-cea8-496d-b29e-8e54624d28f1
- Region: Central US
(The information above is from an app with the repro that is provided below)
#### Repro
```csharp
public static async Task Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
using var request = new HttpRequestMessage(HttpMethod.Get, "https://developers.docusign.com/platform/auth/reference/obtain-access-token/");
using var response = await client.SendAsync(request).ConfigureAwait(false);
// You will see this in the logs in under a second, but function will still be "running"
log.LogInformation("Done");
return response;
}
```
#### Expected behavior
The function should return a 502 Bad Gateway error as soon as the function tries to return the disposed object. In local development, a 500 error is returned within seconds.
#### Actual behavior
The function is Active/Running for over 120 seconds before returning a 502 error. This behavior is observed in Azure.
#### Known workarounds
None
Contributor guide
Research direction
Start with the provided C# HttpTrigger reproduction and compare its local behavior with execution in Azure. Done means returning the disposed HttpResponseMessage produces the expected 502 without the observed 120-second delay; no specific files or tests are named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp
- Domain
- api, backend, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100