[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Task](https://evolu.dev/docs/api-reference/common/Task) › timeout

```ts
function timeout<T, E, D>(
  task: Task<T, E, D>,
  duration: PositiveDuration,
): Task<T, TimeoutError | E, D>;
```

Defined in: [packages/common/src/Task.ts:3684](https://github.com/evoluhq/evolu/blob/a18269a1b822c670b507c6a9b73b23eed32551fe/packages/common/src/Task.ts#L3684)

Limits how long a [Task](https://evolu.dev/docs/api-reference/common/Task/type-aliases/Task) may run.

Returns the Task [Result](https://evolu.dev/docs/api-reference/common/Result/type-aliases/Result) when it settles within the duration.
Otherwise, the Task is aborted and [TimeoutError](https://evolu.dev/docs/api-reference/common/Task/variables/TimeoutError-1) is returned. A Task
that doesn't observe abort delays the TimeoutError until it settles; when
that wait is unacceptable, wrap the Task with [daemon](https://evolu.dev/docs/api-reference/common/Task/functions/daemon):
`timeout(daemon(task), duration)`.

### Example

```ts
import {
  createRun,
  timeout,
  timeoutError,
  waitForAbort,
  type Result,
  type TimeoutError,
} from "@evolu/common";

await using run = createRun();

const result = await run(timeout(waitForAbort, "1ms"));
expectTypeOf(result).toEqualTypeOf<Result<never, TimeoutError>>();
expectErr(result, timeoutError);
```