# abortable

> **abortable**\<`T`\>(`promise`, `signal`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`T`\>

Defined in: [packages/synapse-core/src/utils/abort.ts:33](https://github.com/FilOzone/synapse-sdk/blob/840d7b2c6263846ac51b7558000e62dd68d33a44/packages/synapse-core/src/utils/abort.ts#L33)

Reject with iso-web's AbortError when the signal aborts, otherwise settle like the promise.

The underlying work is not cancelled, only the wait for it. Use it to cancel waits that take no
signal, and to get a plain AbortError from calls on a client scoped with viem's
`client.scope({ signal })`. Those reject with the signal's reason, and contract reads wrap it in
`ContractFunctionExecutionError`.

## Type Parameters

| Type Parameter |
| ------ |
| <a id="type-parameter-t"></a> `T` |

## Parameters

| Parameter | Type |
| ------ | ------ |
| `promise` | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`T`\> |
| `signal` | [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal) \| `undefined` |

## Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`T`\>

## Example

```ts
import { abortable } from '@filoz/synapse-core/utils'
import { getPdpDataSet } from '@filoz/synapse-core/warm-storage'

const dataSet = await abortable(getPdpDataSet(client.scope({ signal }), { dataSetId: 1n }), signal)
```