-
-
Notifications
You must be signed in to change notification settings - Fork 731
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
Task getting cancelled when awaited by AsyncFrostingTask #3462
Comments
Thanks @mandalorianbob Would you be able to provide a minimal reproducible code example? |
I think so, but not this week. I'll gin up something next week and post it. |
CakeRepo.zip However, it appears there might be multiple issues here. Getting it to run reliably is actually very hard, though it doesn't seem like it should be because it's a pretty simple setup. So the original issue is still present. If you remove "TASK_ONLY" from the definitions, it'll switch over to awaiting within the methods, which makes it never run. When I first created it, it used 1.2.0 which I guess it latest, but that crashes on run because of some missing type. So I downgraded to 1.1.0 and I get the issue. It's possible that it was fixed in 1.2.0, but I wouldn't know because I don't know why the other error is happening. It's possible that my setup is unique, but I'm working at a place that has many similar projects that need the same custom build logic. So I'm trying to make it so that someone can grab a library, implement a very simple build project with a custom context, an be good to go with minimum effort. So I'm making a Library for the Cake Tasks. I was making a custom Unity Task that executes a Process when I came across this weird issue where it was hanging. |
I don't know what was happening with my setup before, but I just updated to 1.2.0 and tried again and it ran without error, but successfully reproduced the issue. So the issue appears to still happen in 1.2.0 |
Prerequisites
Cake runner
Cake Frosting
Cake version
1.1.0
Operating system
Windows
Operating system architecture
64-Bit
CI Server
No response
What are you seeing?
My setup is as follows
AsyncFrostingTask.RunAsync awaits
CustomCode.BuildAsync
CustomCode.BuildAsync is a method that returns a Task from a private CustomMethodAsync that also returns a Task, which comes from Process.WaitAsync.
So the async portion is Process.WaitAsync, which should be returned back to AsyncFrostingTask.RunAsync which awaits it.
However, when I do this, I immediately get a "TaskCanceledException" and the Task doesn't run properly.
I put a try/catch around the CustomCode.BuildAsync call, but it doesn't catch anything.
However, when I go into BuildAsync and CustomMethodAsync and make them async methods that await Process.WaitAsync themselves, everything works as expected and the exception doesn't happen.
What is expected?
AsynFrostingTask should run Tasks without arbitrarily canceling them.
Steps to Reproduce
I haven't tried a min repo, but the problem immediately happened when I switched from calling async Task code to calling code that returned a Task without awaiting it, and went away when I switched back.
Output log
No response
The text was updated successfully, but these errors were encountered: