Skip to content

Async computation hanging in lastest F# 4.1 builds #3254

Closed
@eiriktsarpalis

Description

@eiriktsarpalis

While going through the discussion in #3219 I noticed that a particular computation seems to be hanging when run in F# Interactive 4.1

cc @matthid

Repro steps

In F# Interactive 4.1

open System
open System.Threading
open System.Threading.Tasks

let test() =
    let tcs = new TaskCompletionSource<int>()
    let cts = new CancellationTokenSource()
    let _ = cts.Token.Register(fun () -> tcs.SetResult 42)
    async {
        cts.CancelAfter 500
        let! result = tcs.Task |> Async.AwaitTask
        return result
    } |> fun a -> Async.RunSynchronously(a, cancellationToken = cts.Token)

function test does execute as expected.

Expected behavior

Should fail with OperationCanceledException

Actual behavior

Hangs indefinitely

Workarounds

In compiled code, use FSharp.Core nuget package 4.1.17 (containing a version of FSharp.Core.dll 4.4.1.0 that does not contain this problem). Avoid using FSharp.Core nuget package 4.2.1 (which contains this problem).

In F# Interactive code, use a latest update to F# Interactive and your compiler tools (e.g.Visual Studio 2017 Update 3)

Related information

This only occurs in F# interactive 4.1 (32bit and 64bit builds) in both windows and mono/linux. It does not happen in console applications running FSharp.Core 4.4.1.0. I can't reproduce the issue in F# Interactive 4.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-LibraryIssues for FSharp.Core not covered elsewhereBugImpact-High(Internal MS Team use only) Describes an issue with extreme impact on existing code.ReadyRegression

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions