Skip to content

runWithTimeout<Result>

Executes a function with a timeout. If the function does not complete within the specified time, it is considered to have timed out.

Without an onTimeout, a timed-out function is terminated, unless the getTerminateOnTimeoutDebugSwitch debug switch is off, in which case it is allowed to run indefinitely.

Import:

import { runWithTimeout } from '@mnaoumov/typescript-lib/async';

Signature:

function runWithTimeout(params: RunWithTimeoutParams<Result>): Promise<Result>

Parameters:

Parameter Type Description
params RunWithTimeoutParams<Result> The parameters for the function.

Returns: Promise<Result> — A Promise that resolves with the result of the asynchronous function or rejects if it times out.


Links to this page: