Skip to main content

timeout

Callable

  • timeout<Value, Error>(task: TaskLike<Value, Error>, delay: Option<TimeDuration>): Task<Value, TimeoutError | Error>

  • Creates a task that will reject a TimeoutError if task is not resolved or rejected within delay If timeout is omitted, the task is returned unchanged

    @example
    const longTask = Task.delay(TimeDuration.hours(1));
    const timeoutTask = timeout(longTask, TimeDuration.milliseconds(4));
    Task.run(timeoutTask); // Result.Error(TimeoutError({ message: 'Task timed out after 4ms', delay: 4 }))
    // Note that `longTask` will be canceled and will never resolve nor reject

    Type parameters

    • Value
    • Error