withCallTimeout() function

Runs fn with a time limit of its own for every client call made inside it, in place of the client's IMQClientOptions.callTimeout.

Signature:

export declare function withCallTimeout<T>(ms: number, fn: () => T): T;

Parameters

Parameter

Type

Description

ms

number

the limit in milliseconds, as callTimeout takes it: 0, a negative number or Infinity means no limit

fn

() => T

the work whose calls get this limit

Returns:

T

what fn returns

Remarks

The scope covers every call made inside it, on any client, including calls made after an await, in a callback or timer started inside it, and calls a local (in-process) service makes while answering one. A scope inside a scope replaces it until the inner one ends. A requested IMQDelay still adds to the limit. Outside a scope, each client uses its own callTimeout, exactly as before. Nothing about the call on the wire changes: the limit is the caller's alone.

Example

const report = await withCallTimeout(120000, () => reports.build(id));

Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.