Skip to content

timeout

timeout<E>(ms, onTimeout): <A>(task) => Task<Result<E, A>>

Defined in: Core/Task.ts:305

Converts a Task<A> into a Task<Result<E, A>>, resolving to Err if the Task does not complete within the given time. The inner Task receives an AbortSignal that fires when the deadline passes, so operations like fetch that accept a signal are cancelled rather than left dangling.

E

number

() => E

<A>(task): Task<Result<E, A>>

A

Task<A>

Task<Result<E, A>>

pipe(
  heavyComputation,
  Task.timeout(5000, () => "timed out"),
  TaskResult.chain(processResult)
);