Skip to content

ToAsyncEnumerable hides stack traces of errors #2301

@adamjones2

Description

@adamjones2

Repro:

var observable = Observable.Return(1).Select(Test.Throw);

try { await foreach (var x in observable.ToAsyncEnumerable()) { } }
catch (Exception ex) { Console.WriteLine(ex); }

class Test
{
    public static int Throw(int x) => throw new("test");
}

Prints:

System.Exception: test
   at System.Linq.AsyncEnumerable.ObservableAsyncEnumerable`1.MoveNextCore() in /_/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Observable.cs:line 98
   at System.Linq.AsyncIteratorBase`1.MoveNextAsync() in /_/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs:line 70
   at System.Linq.AsyncIteratorBase`1.MoveNextAsync() in /_/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs:line 75
   at Program.<Main>$(String[] args) in Program.cs:line 68
   at Program.<Main>$(String[] args) in Program.cs:line 68

Expect to see mention of the Test.Throw method in the stack trace but everything underneath MoveNextCore is hidden.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions