Skip to content

Timeout

Executes a callback with a server-side time limit.

myScript.Timeout(fn: () => ( T | Promise ), milliseconds: number):( T | "null" )

Parameters

() => ( T | Promise ) fn
    The callback to execute. Server workflow scripts may return a value or a promise.

number milliseconds
    The positive time limit in milliseconds.

Returns

The callback result on success; otherwise null.

Remarks

Server workflow scripts only. null represents both a timeout and a callback failure because the server captures either outcome. Use a result value that can be distinguished from null when that distinction matters. This method does not provide transaction isolation; combine it with Isolated() only when an independent transaction is intentionally required.

Example

1
2
3
4
5
6
7
var result = Script.Timeout(function () {
    return calculateTotals();
}, 1000);

if (result === null) {
    throw new Error("Calculation did not complete.");
}