[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) › AbortableFiber

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

A [Fiber](https://evolu.dev/docs/api-reference/common/Task/interfaces/Fiber) with explicit abort and async-disposal controls.

Calling `.abort()` requests abort for the Fiber's child [Run](https://evolu.dev/docs/api-reference/common/Task/interfaces/Run). If the
Task observes abort or a defect panics the Run tree, the Fiber resolves with
an [Err](https://evolu.dev/docs/api-reference/common/Result/interfaces/Err) containing the [AbortError](https://evolu.dev/docs/api-reference/common/Task/variables/AbortError). Panic uses
[PanicAbortReason](https://evolu.dev/docs/api-reference/common/Task/interfaces/PanicAbortReason); the original defect is available on the reason for
diagnostics.

Use `.abort()` plus `await fiber` for manual lifetime control, or `await
using` for a lifetime bounded by the using block. Async disposal calls
`.abort()` and waits for the Fiber to settle.

### Example

```ts
import {
  AbortError,
  createRun,
  ok,
  sleep,
  type AbortableFiber,
  type Task,
} from "@evolu/common";

await using run = createRun();

const fetchData: Task<string> = async (run) => {
  await run.ok(sleep("1s"));
  return ok("data");
};

const fiber = run.abortable<string, never>(fetchData);
expectTypeOf(fiber).toEqualTypeOf<AbortableFiber<string, never>>();
fiber.abort();
const result = await fiber;
assert(!result.ok);
expect(AbortError.is(result.error)).toBe(true);
```

## Extends

- [`Fiber`](https://evolu.dev/docs/api-reference/common/Task/interfaces/Fiber)\<`T`,
  \| `E`
  \| [`AbortError`](https://evolu.dev/docs/api-reference/common/Task/interfaces/AbortError), `D`\>.[`AsyncDisposable`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management)

## Methods

<a id="asyncdispose"></a>

### \[asyncDispose\]()

```ts
asyncDispose: PromiseLike<void>;
```

Defined in: node\_modules/@typescript/old/lib/lib.esnext.disposable.d.ts:38

#### Inherited from

```ts
AsyncDisposable.[asyncDispose]
```

---

<a id="catch"></a>

### catch()

```ts
catch<TResult>(onrejected?:
  | ((reason: any) =>
  | TResult
  | PromiseLike<TResult>)
  | null): Promise<
  | Result<T,
  | E
  | AbortError>
| TResult>;
```

Defined in: node\_modules/@typescript/old/lib/lib.es5.d.ts:1562

Attaches a callback for only the rejection of the Promise.

#### Inherited from

[`Fiber`](https://evolu.dev/docs/api-reference/common/Task/interfaces/Fiber).[`catch`](https://evolu.dev/docs/api-reference/common/Task/interfaces/Fiber#catch)

---

<a id="finally"></a>

### finally()

```ts
finally(onfinally?: (() => void) | null): Promise<Result<T,
  | E
| AbortError>>;
```

Defined in: node\_modules/@typescript/old/lib/lib.es2018.promise.d.ts:27

Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
resolved value cannot be modified from the callback.

#### Inherited from

[`Fiber`](https://evolu.dev/docs/api-reference/common/Task/interfaces/Fiber).[`finally`](https://evolu.dev/docs/api-reference/common/Task/interfaces/Fiber#finally)

---

<a id="then"></a>

### then()

```ts
then<TResult1, TResult2>(onfulfilled?:
  | ((value: Result) =>
  | TResult1
  | PromiseLike<TResult1>)
  | null, onrejected?:
  | ((reason: any) =>
  | TResult2
  | PromiseLike<TResult2>)
| null): Promise<TResult1 | TResult2>;
```

Defined in: node\_modules/@typescript/old/lib/lib.es5.d.ts:1555

Attaches callbacks for the resolution and/or rejection of the Promise.

#### Inherited from

[`Fiber`](https://evolu.dev/docs/api-reference/common/Task/interfaces/Fiber).[`then`](https://evolu.dev/docs/api-reference/common/Task/interfaces/Fiber#then)

## Properties

<a id="tostringtag"></a>

### \[toStringTag\]

```ts
readonly [toStringTag]: string;
```

Defined in: node\_modules/@typescript/old/lib/lib.es2015.symbol.wellknown.d.ts:174

#### Inherited from

[`Fiber`](https://evolu.dev/docs/api-reference/common/Task/interfaces/Fiber).[`[toStringTag]`](/docs/api-reference/common/Task/interfaces/Fiber#tostringtag)

---

<a id="abort"></a>

### abort

```ts
readonly abort: (reason?: AbortReason) => void;
```

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

### run

```ts
readonly run: Run<D>;
```

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

#### Inherited from

[`Fiber`](https://evolu.dev/docs/api-reference/common/Task/interfaces/Fiber).[`run`](https://evolu.dev/docs/api-reference/common/Task/interfaces/Fiber#run)