API reference@evolu/commonTask › unabortable

const unabortable: <T, E, D>(task: Task<T, E, D>) => Task<T, E, D>;

Defined in: packages/common/src/Task.ts:4863

Makes a Task unabortable after it starts.

Abort requests are masked while the Task runs, so run.signal.aborted remains false inside the Task. This does not force the Task to start after an abort request has already reached its Run; unabortable means the Task is not interrupted once it has started. Disposing the enclosing Run still waits for the Task to settle.

Apply at most one abort behavior helper to a Task: do not wrap the same Task with both unabortable and restore, or apply either helper more than once.

Example

import { createRun, ok, unabortable, type Task } from "@evolu/common";

const commitStarted = Promise.withResolvers<void>();
const finishCommit = Promise.withResolvers<void>();
const commit: Task<string> = unabortable(async ({ signal }) => {
  commitStarted.resolve();
  await finishCommit.promise;
  expect(signal.aborted).toBe(false);
  return ok("committed");
});

await using run = createRun();
const fiber = run.abortable(commit);
await commitStarted.promise;
fiber.abort();
finishCommit.resolve();

expectOk(await fiber, "committed");