fsprojects / FSharpx.Async

Asynchronous programming utilities for F#
http://fsprojects.github.io/FSharpx.Async/
Other
94 stars 31 forks source link

AsyncSeq.toBlockingSeq does not hung forever if an exception is thrown and reraise it outside #21

Closed vasily-kirichenko closed 9 years ago

vasily-kirichenko commented 9 years ago

The bug:

asyncSeq {
    yield 1
    failwith "error"    
} 
|> AsyncSeq.toBlockingSeq
|> Seq.iter (printfn "%A")

output: 1, then hungs forever

Now the output is like this:

1

Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.Exception: error
   at Microsoft.FSharp.Core.Operators.Raise[T](Exception exn)
   at FSharpx.Control.AsyncSeq.iterator@385-5.Invoke(Unit _arg2) in L:\github\FSharpx.Async\src\FSharpx.Async\AsyncSeq.f
s:line 385
   at Microsoft.FSharp.Control.AsyncBuilderImpl.args@787-1.Invoke(a a)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at FSharpx.Control.AsyncSeq.loop@390-33.GenerateNext(IEnumerable`1& next) in L:\github\FSharpx.Async\src\FSharpx.Asyn
c\AsyncSeq.fs:line 391
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.MoveNextImpl()
   at Microsoft.FSharp.Collections.SeqModule.Iterate[T](FSharpFunc`2 action, IEnumerable`1 source)
   at Program.main(String[] _arg1) in L:\github\FSharpx.Async\ConsoleApplication1\Program.fs:line 5
forki commented 9 years ago

/cc @tpetricek

forki commented 9 years ago

released in 1.11.1