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

Timeout async guard inappropriately triggers with F# #2892

Closed
bradwilson opened this issue Feb 22, 2024 · 2 comments
Closed

Timeout async guard inappropriately triggers with F# #2892

bradwilson opened this issue Feb 22, 2024 · 2 comments

Comments

@bradwilson
Copy link
Member

Reported here: #2222 (comment)

Sample code that fails to run with 2.7.0:

module Tests

open System.Threading.Tasks
open Xunit

[<Fact(Timeout = 3000)>]
let TestMethod() =
    task {
        Task.Delay(10) |> Async.AwaitTask |> ignore
        Assert.Fail("Make sure things waited")
    }

Adding :> Task cast to the end of the task lambda is a temporary workaround:

module Tests

open System.Threading.Tasks
open Xunit

[<Fact(Timeout = 3000)>]
let TestMethod() =
    task {
        Task.Delay(10) |> Async.AwaitTask |> ignore
        Assert.Fail("Make sure things waited")
    } :> Task
@bradwilson
Copy link
Member Author

The "culprit" here is the new task keyword, which I wasn't familiar with. Instead of returning an FSharpAsync<T>, it returns Task<T>, presumably for better cross-language interop.

@bradwilson
Copy link
Member Author

Available in v2 2.7.1-pre.7
Available in v3 0.1.1-pre.378

https://xunit.net/docs/using-ci-builds

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

No branches or pull requests

1 participant