Skip to content

[Bug]: OnItemRemoved swallows exception from upstream #1061

@gewald314

Description

@gewald314

Describe the bug 🐞

ObservableListEx.OnItemRemoved swallows exceptions which are thrown in the upstream. See Step to reproduce below.

Step to reproduce

public void TestExceptionInUpstream()
{
    bool thrown = false;
    SourceList<int> list = new SourceList<int>();
    list.Connect()
        .Do(_ =>
        {
            thrown = true;
            throw new InvalidOperationException("Test");
        })
        .OnItemRemoved(_ => {})
        .Subscribe();

    list.Add(1); // This should throw, but does not.

    Console.WriteLine($"thrown: {thrown}."); // We should never get here, but get this line in the console output.
}

Reproduction repository

N/A

Expected behavior

public void ExpectedBehavior()
{
    bool thrown = false;

    SourceList<int> list = new SourceList<int>();
    list.Connect()
        .Do(_ =>
        {
            thrown = true;
            throw new InvalidOperationException("Test");
        })
        .OnItemAdded(_ => { })
        .Subscribe();

    list.Add(1); // This throws the exception.

    Console.WriteLine($"thrown: {thrown}."); // We never get here.
}

Screenshots 🖼️

No response

IDE

No response

Operating system

No response

Version

No response

Device

No response

DynamicData Version

9.4.1

Additional information ℹ️

Maybe this is related to dotnet/reactive#1904

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