Skip to content

withSignal

withSignal<transport>(transport, signal): transport

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

Wrap a viem transport so its requests reject with iso-web’s AbortError once the signal aborts.

Type Parameter Description
transport extends Transport The transport to wrap.
Parameter Type Description
transport transport -
signal AbortSignal | undefined The signal to abort requests. The transport is returned as is when undefined.

transport

The wrapped transport.

import { createPublicClient, http } from 'viem'
import { calibration } from '@filoz/synapse-core/chains'
import { withSignal } from '@filoz/synapse-core/utils'

const controller = new AbortController()
const client = createPublicClient({
  chain: calibration,
  transport: withSignal(http('https://my-rpc.example.com'), controller.signal),
})