-
Notifications
You must be signed in to change notification settings - Fork 450
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
Azure Functions throw TaskCanceledException #5216
Comments
@Francisco-Gamino can you investigate? |
I got the same error, in my case the project was created using the cmd: Error detail: System.Threading.Tasks.TaskCanceledException
HResult=0x8013153B
Message=A task was canceled.
Source=System.Private.CoreLib
StackTrace:
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.MetricsEventManager.FunctionActivityTracker.<<-ctor>b__8_0>d.MoveNext() in C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Diagnostics\MetricsEventManager.cs:line 341 |
Any news on this issue? for me this is happening in 1.0 az function. after it run for some time, exactly 229936ms (around 1 hour) i don't think this is function timeout, my function is on an app service so the timeout should be zero as default. |
I can duplicate as well, but calling multiple HTTP clients simultaneously to the same HTTPTrigger. For example, when starting 20 simultaneous calls, 5 will error with the TaskCanceledException within the first 30 seconds. |
Hi @ankitkumarr, could you please take a look? If this is not Core-Tools related, we'll move it to the correct repo. Thanks. |
I am also experiencing this issue - is there any update? |
This looks like a host issue. Moving to that repo. |
@yojagad would you have an insight on this? I remember you were doing some stuff with |
I would be good to have at least a vague explanation for this as we are also experiencing this issue. Whilst not a show stopper for us it is at the very least inconvenient. |
I'm getting the same error. When I activate historical debugging, it appears to be in the MetricsEventManager.cs in Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics The exception is thrown at on this line, in the FunctionActivityTracker
` |
Thanks @mikelor for sharing that. That is weird that the exception from there is being bubbled up. As you can see, there is a I am having a hard time reproing this. I even added code to manually cancel the cancellation token right before that line, and it gets accurately handled in the catch block. I will look more into this. Adding @fabiocav as he may have some insight on why this is bubbling up, or a workaround. What version of core-tools / Azure Functions Runtime are you on? You can check by running |
Hi @ankitkumarr, I created a simple app the repros the problem when reading from a Service Bus queue. See the TaskCanceledFunctionApp repo. As you mentioned the Exception gets handled, so it's probably okay. I'm showing the exceptions occurring in the debugger, but since their being swallowed up, everything continues to run. Is this the "expected behavior"? Looks like it, but would like some confirmation.
This sample writes to a Service Bus Queue via a Timer Trigger and reads from the queue via a Queue Trigger. Also included is a createResourceGroup.sh shell script that will create the Azure Service Bus to write/read from. This successfully reproduces the
I'm using Visual Studio cc: @fabiocav |
Any updates or workaround? I am having the same issue. |
Do not use async void - change it to async Task instead. |
same problem, with function defined using "async Task". Same exception every execution. Funny... Converted back to non-async, but every execution is STILL throwing a task canceled exception from System.Private.CoreLib.dll |
@yangyadi1993 @LarrySmith-1437 is this with the same stack shared above? If so, this is not an exception that will impact runtime behavior. |
@fabiocav I updated my comment above, it's happening elsewhere once I made my method non-async. So now it's not throwing from my code, but somewhere else. |
Understood, but is this causing a runtime exception that is impacting your application, or are you seeing that in VS while debugging and setting exceptions to throw? If your stack is different, can you please open a separate issue with the details? Thanks! |
Does not seem to be impacting execution, except of course it does draw some attention and one would love to know where/why the exception is happening prior to putting code into production. I found it interesting that the exception is being thrown whether the Run method is async or not. |
I was missing an await keyword for my method. Make sure all your async methods contain await keyword. |
Closing as resolved. |
Create new Azure Function 2.0 project with an HttpTrigger function. Run it locally. Open the URL to trigger the funtion
Systems.Threading.Tasks.TaskCanceledException
in System.Private.CoreLib.dll
"A task was cancelled"
This happens for each request.
More details in this bug report : https://developercommunity.visualstudio.com/content/problem/549316/azure-functions-throw-taskcanceledexception.html
The text was updated successfully, but these errors were encountered: