Cancelling browser operation throws an error

Hi,

If a browser operation (f.e. attach) is being cancelled, it throws following error:

PickTest has thrown an exception Message: The activity 'Launch Workflow Interactive' with ID 7 threw or propagated an exception while being canceled. Exception Type: InvalidOperationException System.InvalidOperationException: The activity 'Launch Workflow Interactive' with ID 7 threw or propagated an exception while being canceled. ---> System.InvalidOperationException: The activity 'Attach Browser 'iexplore.exe Google'' with ID 3 threw or propagated an exception while being canceled. ---> UiPath.Core.BrowserOperationException: Operation was canceled. ---> System.Runtime.InteropServices.COMException: Operation was canceled. at UiPath.UiBrowserClass.Find(String bstrSelector) at UiPath.Core.Browser.Find(Selector selector) --- End of inner exception stack trace --- at UiPath.Core.Activities.ScopeActivity.EndExecute(NativeActivityContext context, IAsyncResult result) at UiPath.Core.Activities.AsyncNativeActivity.BookmarkResumptionCallback(NativeActivityContext context, Bookmark bookmark, Object value) at System.Activities.Runtime.BookmarkCallbackWrapper.Invoke(NativeActivityContext context, Bookmark bookmark, Object value) at System.Activities.Runtime.BookmarkWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager) --- End of inner exception stack trace --- at UiPath.Core.Activities.InvokeWorkflowFile.EndExecute(AsyncCodeActivityContext context, IAsyncResult result) at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result) at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager) --- End of inner exception stack trace ---

This is not consistent with AttachWindow, TypeInto or other activities that can be cancelled normally.

Edit: Since an error thrown during cancellation is equivalent to throwing from Catch block or using TerminateWorkflow it bypasses immediate level TryCatch making it very awkward to design around.

Regards.

hi andrzej.kniola

i have tried to reproduce the problem, but i`m having trouble canceling the workflow right after run. the attach activity happens instantly and there is no time to stop it from studio
how do you reproduce this, can you give us more details?

thank you very much.

Hi Gabriel,

Please find attached a repro example - it’s a parallel setup with a failing Attach in one branch and delay (essentially a timeout equivalent) in the second branch.

PickTest.xaml (7.3 KB)

Regards.

will have a go and get back to you.

@Gabriel_Tatu
Was this ever fully diagnosed? We’ve had this (or very similar) situation in one of the robots yesterday evening.

Hi Guys, do you know how fix handle that error? I have one similar and I don`t know how to handle …

System.InvalidOperationException: The activity ‘WaitImageAppear’ with ID 36 threw or propagated an exception while being canceled. —> UiPath.Core.Activities.ActivityTimeoutException: Activity timeout exceeded
at UiPath.Core.Activities.WaitImageAppear.EndExecute(NativeActivityContext context, IAsyncResult result)
at UiPath.Core.Activities.AsyncNativeActivity`1.BookmarkResumptionCallback(NativeActivityContext context, Bookmark bookmark, Object value)
at System.Activities.Runtime.BookmarkCallbackWrapper.Invoke(NativeActivityContext context, Bookmark bookmark, Object value)
at System.Activities.Runtime.BookmarkWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
— End of inner exception stack trace —
at UiPath.Core.Activities.InvokeWorkflowFile.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

Hi Carmen,

What Studio version do you have? This was fixed in the last version 2017.1.6522.

1 Like

image Yes I’m working in the last one. But I was reading how to handle exceptions and I found that is better using invoke workflow file and sorrounded by a try catch and I did and works ok.

1 Like

Hi,

I received also “threw or propagated an exception while being canceled” kind of error message and problem was that it was not caught by Try-catch in same workflow. Try-catch at higher level workflow caught it.

What is causing this kind of problem and how to catch those exceptions?

I think the problem is related with activities that contain non Thread Safe variables, because this is usually happening while using Parallel or Pick activities and trying to cancel the branch that contains any UiPath activity but especially Ui interacting ones.

@2aozturk You’re right! I encountered this error when I used a Parallel activity and set the Isolated property on invoked workflows within the parallel activity.

Is this a UiPath bug?

Actually it depends on what perspective you’re looking.

If anyone wants to use parallel threads then she/he needs to make sure using thread safe variables/objects in each thread otherwise accessing the same object at same time by different threads will cause failures in any of the threads. I think this is exactly what is happening in this case. Cancelling thread can’t be cancelled because cancelling activity is trying to do something with non-thread-safe variable/object. Usually in this case the only affected thread should be the failed one and all the other threads should be working fine but because of the nature of Parallel/Pick activity any failed thread will cause the Parallel/Pick activity itself to fail. Unfortunately this is not something we can manage completely with try-catches or any other methods because the exception is being raised in a place that we can’t catch. UiPath needs to help us by reviewing it’s UI interacting activities in thread safety perspective. Until then, I’m afraid we need to give up using parallely working activities instead need to make our checks sequentially to make it sure it will work completely without these kinds of errors. I know this is causing a performance issue but this is the only thing we have. I also mainly see this problem with UI interacting activities.

Thanks…

2 Likes

Hi @loginerror. When you have a moment could you please review @2aozturk’s insightful response to the issue of uncatchable exceptions caused when using cancelling a non-thread safe activity in a Parallel activity thread in UiPath? We’re experiencing the same issue with cancellation of Attach Browser activities that are running in parallel. Interestingly, I don’t have any issue with Find or Attach Window activities when running in parallel, so I’m guessing something about the Attach Browser activity makes it non-thread safe, to @2aozturk’s point. I’m more than happy to log a ticket with Support to review, if you think that would be of benefit.

Hi @mark.bullard

Would you mind creating a sample project that reproduces this issue with a public website and then submit that project, as well as all the contextual info (like a link to this topic) via the Studio feedback feature?

Then either me or @Pablito will process it further and it will be reviewed by our engineers :slight_smile:

1 Like

Hi @loginerror and @Pablito,

Many thanks for your time in review. I’ve attached a sample project as requested that demonstrates how a cancellable Parallel activity (Condition argument set to True) with Attach Browser(s) within one or more threads results in an uncatchable exception. I’ve included a Try-Catch to demonstrate how the exception generated isn’t caught by the catch and instead results in the entire workflow throwing an exception related to the uncancellable activity.

Here is a zipped package:
TEST_ParallelAttachBrowserError.zip (20.9 KB)

Here is the sequence xaml by itself:
project.json (1004 Bytes)

Let me know if there’s any other support I can provide. I’m happy to log a ticket with Support if needed. I’ve started converting many of our libraries’ Parallel activity threads to use Attach Window or simply Find rather than Attach Browser as they both appear to be cancellable without issue. This approach works well, except that Attach Browser tends to work best when attaching using a URL root. It would be great if we could have clarity on what activities are considered non-cancellable - if UiPath Studio natively understood those activities, perhaps it could notify the developer in UiPath Studio that a non-cancellable activity was included in a cancellable Parallel activity (only when the Parallel activity’s Condition is set to True).

Thanks for providing the project, I’ve registered the bug in our tracker.

I will not be able to provide any specific timeline just yet, but our team will evaluate and prioritize it accordingly.

1 Like