Skip to content

Exceptions thrown can sometimes result in two error dialogs #1796

Open
@PathogenDavid

Description

@PathogenDavid

This came up as an unrelated bug discovered via #1787

This happens due to the two HandleWorkflowError calls below:

catch (Exception ex)
{
HandleWorkflowError(ex);
shutdown.Dispose();
throw;
}
},
resource => resource.Workflow.TakeUntil(workflowBuilder.Workflow
.InspectErrorsEx()
.Do(RegisterWorkflowError)
.IgnoreElements()))
.SubscribeOn(NewThreadScheduler.Default.Catch<Exception>(HandleSchedulerError))
.Subscribe(unit => { }, HandleWorkflowError, HandleWorkflowCompleted);

First the call on line 1231 invokes the main thread to display the error, then the exception is rethrown on line 1233. It's then caught a second time by the onError handler on line 1241.

If I remember correctly, during a more typical exception the first call will show a dialog but the second one will only highlight the node and put the exception in the status bar.

This difference comes down to the status of building in the first branch here:

if (workflowException != null && workflowException.Builder != null || exceptionCache.TryGetValue(e, out workflowException))
{
workflowError = workflowException;
HighlightExceptionBuilderNode(workflowException, building);
}
else editorSite.ShowError(e.Message, Name);

It is however worth noting that two dialogs will appear no matter what when the second branch is entered. (As with the original 1787 fix.) So even if this comes down to something related to building there's still the potential for issues.

The handle call on line 1231 was added by 724b2e0 which was trying to fix a bug introduced by 9c8e390 for #908

We theorized that potentially this fix was actually trying to fix what was actually a race condition in reading building by HandleWorkflowError, but there's not enough context to say for sure. (See #1795)

We agreed it didn't make much sense to have two HandleWorkflowError calls here, but because the issue supposedly fixed by 9c8e390 is pretty serious (two error dialogs is practically benign compared to completely silent errors), we don't want to risk a regression here by reverting that commit blindly and decided this issue warrants further investigation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions