ExecutionTimeout / ExecutionTimeLeft
ts
function ExecutionTimeout(): number;
function ExecutionTimeLeft(): number;ExecutionTimeout() returns the configured execution timeout in seconds for the script currently being run. Returns 0 when no timeout is set.
ExecutionTimeLeft() returns the number of nanoseconds remaining before the script deadline. Returns 0 when no timeout is set, or when time has already run out.
NOTE
Divide ExecutionTimeLeft() by 1e9 to convert to seconds.
Example
ts
Log("Timeout: " + ExecutionTimeout() + "s");
var leftNs = ExecutionTimeLeft();
var leftSec = leftNs / 1e9;
if (leftSec < 10) {
Log.Warn("less than 10 seconds left, skipping optional step");
} else {
// run the expensive optional operation
}TIP
Use ExecutionTimeLeft() in the condition of long inner loops so the script can exit cleanly before the hard deadline, rather than being forcibly interrupted mid-operation.
