ExecutionTimeLeft()
ts
function ExecutionTimeLeft(): number;Returns the number of nanoseconds remaining before the script deadline. Returns 0 when no timeout was set or when time has already run out.
Use this to decide whether enough time remains for an expensive operation before committing to it.
NOTE
Syncplify Server! enforces a maximum execution time for scripts to prevent runaway or excessively long-running processes. Use ExecutionTimeLeft() to check how much time your script has left to complete its work. Divide by 1e9 to convert to seconds.
Example
ts
{
var leftNs = ExecutionTimeLeft();
var leftSec = leftNs / 1e9;
Log("Seconds left: " + leftSec);
if (leftSec < 5) {
Log("Warning: script is about to time out, skipping optional step");
} else {
// run the optional expensive operation
}
}TIP
Always check the remaining time in long-running or complex scripts to avoid unexpected termination and ensure proper cleanup.
