This delay in execution could be attributed to various possible environmental conditions (network latency, resource unavailability, high resource usages).
Release: DSWAHA01300-12-Workload Automation DE-High Availability
To fix this issue, we can increase the the "maximum run time of a java script" parameter value from the Desktop Client.
On the Desktop Client, Admin -> Topology -> Server Shared Parameters -> "maximum run time of a java script (seconds)" default is 300 seconds.
Set this value to a higher value to ensure that the java script execution is not interrupted due to timeout.