-
Notifications
You must be signed in to change notification settings - Fork 441
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
Proxy not forwarding cancellation token to app correctly in WebJobs.Script.Grpc/Server/RetryProxyHandler.cs #10600
Comments
This is perfect, thank you! Will add this to todo list :) edit: @stuartf-aida any chance you have a minimal repro I can use to investigate the issue? Or other info on the type of function that is failing with this error i.e. is it a dotnet-isolated app? v4? .net 6 or .net 8? what kind of trigger binding? etc. |
@liliankasem We've shifted our code now to use an alternative, based on the workaround for the previous issue where I originally posted. That seems (so far) to have solved this, but it's hard to say. We don't (and didn't) have a situation that reliably caused this to happen - most invocations would not error. We can use the same payload on the http trigger such that the same code runs and we've not successfully reproduced the issue. The function doesn't do very much. It uses Azure.Security.KeyVault.Secrets (4.7.0) to grab a secret from the keyvault, and along the way a bit of string manipulation Thanks very much for your keen attention on these issues! |
Okay so it looks like we have a fun two part bug. HostThe first part is in the host. The
azure-functions-host/src/WebJobs.Script.Grpc/Server/DefaultHttpProxyService.cs Lines 55 to 66 in 287ceac
WorkerThere is also a bug in the AspNetCore worker extension which breaks the cancellation behaviour. In the var contextRef = _contextReferenceList.GetOrAdd(invocationId, static id => new ContextReference(id));
contextRef.SetCancellationToken(context.CancellationToken);
contextRef.FunctionContextValueSource.SetResult(context); As a result, when a function invocation is cancelled, we cancel that same cts that is being used by ContextReference: cancellationTokenSource?.Cancel(); So, we end up with a disposed HttpContext when we try to handle the invocation result: ActionContext actionContext = new ActionContext(httpContext, httpContext.GetRouteData(), new ActionDescriptor());
await actionResult.ExecuteResultAsync(actionContext); This is where the ObjectDisposedExecpetion comes from:
Next StepsI'll speak with the team and discuss how we want to handle these issues.
|
Proxy not forwarding cancellation token correctly to function app
Canada Central example @pmerineau
first reported Azure/azure-functions-dotnet-worker#2417 (comment)
North Europe example @stuartf-aida
first reported Azure/azure-functions-dotnet-worker#2417 (comment)
As mentioned by @liliankasem
I hope this is what you need, Lilian!
The text was updated successfully, but these errors were encountered: