Skip to content

[BUG] ReactiveCommand's IsExecuting not set to False after command throwing exception #2859

@exrezzo

Description

@exrezzo

Describe the bug
If a command throws an exception the IsExecuting observable is not set to False

Steps To Reproduce
This is a test to reproduce the issue. Thanks to @anaisbetts and @glennawatson for the constant support on Slack.

        [Fact]
        public void Test1()
        {
                    var subj = new Subject<Unit>();
                    var isExecuting = false;
                    Exception fail = null;
                    var fixture = ReactiveCommand.CreateFromTask(async _ => {
                    await subj.Take(1);
                    throw new Exception("die");
                    });
                    fixture.IsExecuting.Subscribe(x => isExecuting = x);

                    Assert.False(isExecuting);
                    Assert.Null(fail);

                    fixture.Execute().Subscribe();
                    Assert.True(isExecuting);
                    Assert.Null(fail);


                    subj.OnNext(Unit.Default);
                    Assert.False(isExecuting);  //here it fails
                    Assert.NotNull(fail);
        }

Expected behavior
IsExecuting should be set to False after exception

Environment
Blazor Server on .NET 5

  • OS: Windows 10

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