Skip to content

abortable

abortable<T>(promise, signal): Promise<T>

Defined in: packages/synapse-core/src/utils/abort.ts:32

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, such as viem’s waitForTransactionReceipt, and to get a plain AbortError from contract reads on a withSignal client, which viem wraps in ContractFunctionExecutionError.

Type Parameter
T
Parameter Type
promise Promise<T>
signal AbortSignal | undefined

Promise<T>

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

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