Skip to content

MaintenanceThe former company search endpoint goes into maintenance on November 9Migration guide

SDKs // TypeScript // Guides

Timeouts and cancellation

Last verified

Set per-attempt HTTP timeouts, bound asynchronous job waits, and cancel local requests with AbortSignal in the Reverse Contact TypeScript SDK.

Use request timeouts for individual HTTP attempts and a wait deadline for the full polling loop.

Request timeouts and cancellation

Each HTTP attempt times out after 90 seconds by default, since some enrichments take more than 60 seconds. Pass request options as the last argument of any API method: timeout (milliseconds per attempt), maxRetries, headers and signal.

Use an AbortSignal to cancel a request, the wait between retries, or job.wait(). A cancelled call raises APIConnectionError. Cancellation stops your code from waiting, without cancelling the job on the server.

TypeScript SDK

Timeout and cancellation

import ReverseContact from "@reverse-contact/sdk";

const client = new ReverseContact({ apiKey: process.env.RC_API_KEY });

const usage = await client.usage.retrieve({
  timeout: 10_000,
  maxRetries: 1,
  signal: AbortSignal.timeout(30_000)
});
console.log("Credits left:", usage.quotas?.workspace.credits.left);

Wait options

job.wait(), client.jobs.wait(), client.bulk.wait() and client.lists.operations.wait() accept WaitOptions<T>:

OptionTypeDescription
timeoutnumberOverall deadline in milliseconds, 1,800,000 by default (30 minutes). Must be positive and finite.
pollWaitnumberHow long each poll waits, in seconds. An integer from 0 to 20 that defaults to 20.
onPoll(snapshot: Result<T>) => void | Promise<void>Called with each response envelope. Read progress in snapshot.data.
headersRequestInit["headers"]Headers for polling requests.
signalAbortSignalCancels the local wait.

WaitOptions has no maxRetries. Each poll uses 4 retries within the overall deadline. Polling reads allow at least wait + 15 seconds for an HTTP attempt, but wait() remains bound by the overall deadline.

When the wait deadline passes, the SDK raises JobTimeoutError with jobId and lastStatus. The server job may continue. See Async jobs to resume waiting. To request a server-side stop for a Bulk job or List operation, use client.bulk.cancel() or client.lists.operations.cancel().

Return to the TypeScript SDK overview.

FAQ

What is the default HTTP timeout in the TypeScript SDK?

Each HTTP attempt times out after 90 seconds by default. Set the request or client timeout in milliseconds to change that deadline.

Does AbortSignal cancel a job on the server?

AbortSignal stops the SDK request or local polling loop and raises APIConnectionError. The server job can continue. Bulk and List operations have separate cancel methods.

How do I change the deadline for job.wait?

Pass timeout in milliseconds to job.wait(). The wait deadline defaults to 30 minutes and raises JobTimeoutError when exceeded.