> ## Documentation Index
> Fetch the complete documentation index at: https://acme-c84a37e5.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Abort Handling

> Cancellation with AbortSignal and abort error handling

## Recommended pattern

```typescript theme={null}
import { run } from "tryo";

const controller = new AbortController();
const r = await run(() => fetch("/api", { signal: controller.signal }), {
  ignoreAbort: true,
  onAbort: (s) => console.log("abort"),
});
controller.abort();
```

With `ignoreAbort: true`, aborts do not trigger `onError` and return an error result with code `ABORTED`.

## In React

```tsx theme={null}
useEffect(() => {
  const c = new AbortController();
  run(() => fetch("/api", { signal: c.signal }), { ignoreAbort: true });
  return () => c.abort();
}, []);
```
