Buggy behaviour with Queue<T>.Dequeue() function in Studio debugger

In a UiPath project, I have encountered a very strange issue: One activity seems as if it’s executed twice each time the robot is manually stepped through it while debugging in Studio.

My Studio version is 2021.10.5.

I have two variables,

  • TransactionQueue (Queue<Object>)
  • TransactionItem (Object)

At one point, the queue contains three objects inside of it:
image

The robot is executing the Assign activity where the first object is supposed to be extracted from the queue using Dequeue() function and assigned to TransactionItem variable:
image

Just prior to executing the activity, debugger correctly shows what should happen once the activity executes:
image

And yet, the result of executing the activity is that TransactionItem has been assigned the value 3, and two items have been removed from the TransactionQueue, as if Dequeue() had been called twice:
image

This only happens when I step into/over the Assign activity using the debugger, not when the robot is allowed to freely run on its own through the activity.

This sure seems like a debugger-related bug to me.

2 Likes

We are noticing the exact same behavior as well. Definitively a debugger issue. Would be great if this could be fixed.

I wish I had seen this post before spending over an hour trying to solve this same issue. I even tried this with ConcurrentQueue<T> and got the same bug occurring in Debug mode.

This really should be fixed whenever possible, especially because UiPath recommends Queue<T> for designing transaction-based processes without Orchestrator:

Edit: tried with several other collections (Stack/ConcurrentStack, BlockingCollection, and ConcurrentBag) and all of them have this same issue.

Hey everyone,

What a timely reply of mine :sweat_smile:

I wanted to offer a workaround to the issue that seems to work, which is to use the Invoke Method activity.

Please refer to the below video:

Because it works as expected with the Invoke Method, which is a solid workaround, I don’t think we will be fixing this for the Assign activity anymore.