Terminal Activities - Close Connection does not work

@bogdan.gaspar Thank you for taking the time to help us with this issue.

The main challenge we’re facing is the need to maintain a single terminal connection across multiple activities spread across several workflows. These workflows are connected through invoke activities, all using the same connection string as an in_argument.

The issue arises when a System Exception occurs. When this happens, the transaction moves to the KillAllProcesses workflow, but the connection string arrives empty. I believe this behavior is tied to a broader issue I’ve encountered in UiPath: if there’s an out_argument in a workflow and a System Exception occurs, the argument value is cleared—even if it was populated before the exception.

Side Note on the Argument Bug:
A workaround I’ve found for this issue is to use a dictionary of arguments instead of single values. For example, if you’re working with strings, create a Dictionary<String, String> and store the argument value inside the dictionary. This way, even after a System Exception, the value isn’t cleared.

Returning to the Terminal Issue:
To ensure the connection is closed every time, we’ve implemented a workaround:

  1. We use a single connection string for the entire transaction.
  2. To set up the connection, we create a dedicated empty terminal session at the start, which only handles the connection initialization - just like you suggest.
  3. We assign the connection string to two argument variables:
  • One variable travels through all the workflows, keeping them connected.
  • The other variable is reserved exclusively for the KillAllProcesses workflow.

Even if a System Exception occurs and clears the argument travelling through the workflows, the connection is still closed because the second argument (used only in KillAllProcesses) remains unaffected.

I understand this might still sound a bit convoluted, but it has worked reliably for us to handle exceptions and maintain proper connection closure.

I can’t share any images right now since I’m currently on vacation, but I passed your messages to my team. Maybe they can figure out a better way to handle this issue with your suggestions and if they do, I’ll let you know once I’m back.