You are viewing limited content. For full access, please sign in.

Question

Question

Workflow Script Timeout Question

asked on August 19, 2019 Show version history

I have a Workflow that I have attempt to run an .exe file with a somewhat heavy load inside a try-catch (in the script.) It tries to run the .exe, and if there is any sort of issue, I have it wait 15 minutes by having the thread sleep and try again up to 5 times. If it didn't run successfully then I have it throw an Exception.

 

The default timeout for WF scripts is 2 minutes. Will this cause issues? Do I need to increase that to 15 minutes? Or is there a better way to handle this?

 

As it stands, I always get an "Object has been disconnected or does not exist at the server" warning even when it runs successfully. Even with the script activity set to report unhandled script exceptions as Errors by default, the "Object has been disconnected" only shows as a warning, so if the script fails it continues onto the next activity anyway even though it's inside a Try-Catch branch. Then the Query Rows activity fails because the CSV it's trying to query doesn't exist since the script failed.

 

0 0

Replies

replied on August 19, 2019

You'd have to set the script timeout to 75 minutes in this case. The script timeout applies to all scripts so I wouldn't recommend it. If multiple instances of this workflow are expected to run concurrently, an instance waiting 75 minutes in an "actively running" state would be taking up resources and preventing others from running.

It would be more efficient to let the exception propagate out of the script and add a task error handler for it. That way the Workflow server will retry for you at the specified interval and resources would be released in between tries. In order for this to work, you'll need to set the script activity to return exceptions as warnings and check for retryable errors.

0 0
replied on August 19, 2019

Would this work even though the "Object has been disconnected" issue is a warning, not an error? I thought a task error handler would only be possible for errors, not warnings.

 

Also, multiple instances of the workflow do NOT run concurrently. This runs once per day at midnight and finishes after 4-5 hours.

0 0
replied on August 19, 2019 Show version history

The Workflow server's script timeout stops waiting for the script to finish once the specified duration has been exceeded. If your script looks for the file, can't find and goes into its retry behavior, the script timeout shouldn't be triggered since, presumably, these actions are faster than 2 minutes. Because the script is no longer actively running during the retry wait period, the timeout won't apply.

edit: The task error handler takes care of errors. Adding a handler changes an error into a warning because at this point Workflow knows what to do when it runs it.

0 0
replied on August 19, 2019

Is it possible that this is what's happening?

-Script runs with a Process.Start action on an exe with the end result of producing a zip file

-Attempt to extract zip file in a try block does not wait for Process.Start to complete

-Since the zip is not there yet, goes to catch block where it waits 15 minutes

-Since the 15 minutes is longer than the 2 minute default timeout, this produces the warning

-If the zip happens to be there now, process completes successfully

-If it is not there yet, then it will keep trying and failing because of the 2 minute timeout

 

In other words, if I put a wait of 1 minute or so before it first tries to extract the ZIP for the first time to ensure the Process.Start completes first, I wouldn't need to change the 2 minute default timeout and it should work without hitting the catch block, at least from my perspective. I'll try that.

0 0
replied on August 20, 2019

Correct, Process.Start does not wait for the process you started to complete.

If the script gets killed by the timeout, it would only produce a warning, so the Catch block is not triggered. The script would have to throw an error and finish within the timeout limits to go into the Catch block.

Whatever the script is doing will continue after the timeout, Workflow just stops waiting for it.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.