Skip to content
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

Open
2 tasks done
mandalorianbob opened this issue Sep 10, 2021 · 4 comments
Open
2 tasks done

Task getting cancelled when awaited by AsyncFrostingTask #3462

mandalorianbob opened this issue Sep 10, 2021 · 4 comments

Comments

@mandalorianbob
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

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

@augustoproiete
Copy link
Member

augustoproiete commented Sep 11, 2021

Thanks @mandalorianbob Would you be able to provide a minimal reproducible code example?

@mandalorianbob
Copy link
Author

I think so, but not this week. I'll gin up something next week and post it.

@mandalorianbob
Copy link
Author

CakeRepo.zip
I've got a repo in here for 1.1.0

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.
However, even running it is with just the task is difficult. The easiest way to ensure it runs completely seems to be to step through. For some reason it keeps hanging midway through the process, which I hadn't run into before.

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.

@mandalorianbob
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants