Skip to content

Task getting cancelled when awaited by AsyncFrostingTask #3462

@mandalorianbob

Description

@mandalorianbob

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions