Options that can be customized when making an RPC call

interface RpcCallOptions {
    abortSignal?: AbortSignal;
    chainId?: string | number;
    dcId?: number;
    floodSleepThreshold?: number;
    kind?: ConnectionKind;
    localMigrate?: boolean;
    manager?: DcConnectionManager;
    maxRetryCount?: number;
    throw503?: boolean;
    timeout?: number;
}

Properties

abortSignal?: AbortSignal

Abort signal for the call.

chainId?: string | number

Some requests should be processed consecutively, and not in parallel. Using the same chainId for multiple requests will ensure that they are processed in the order of calling .call().

Particularly useful for messages.sendMessage and alike.

dcId?: number

ADVANCED

ID of the DC to use for this call

floodSleepThreshold?: number

If the call results in a FLOOD_WAIT_X error, the maximum amount of time to wait before retrying.

If set to 0, the call will not be retried.

Only applies when the flood waiter middleware is enabled.

ADVANCED

Kind of connection to use for this call.

'main'
localMigrate?: boolean

Whether the X_MIGRATE_%d errors should be handled locally on request level instead of changing the default datacenter for the entire client.

Useful for invokeWithBusinessConnection, as it returns a USER_MIGRATE_%d error that is in fact not related to the user, but to the specific request.

manager?: DcConnectionManager

ADVANCED

DC connection manager to use for this call. Overrides dcId if set.

maxRetryCount?: number

If the call results in an internal server error or a flood wait, the maximum amount of times to retry the call.

Only applies when the flood waiter middleware and/or internal errors handler middleware is enabled.

throw503?: boolean

Whether we should not retry on -503 errors and throw MtTimeoutError immediately instead.

Useful for methods like messages.getBotCallbackAnswer that reliably return -503 in case the upstream bot failed to respond.

Only applies if the internal error handler middleware is enabled, otherwise -503 is always thrown.

timeout?: number

Timeout for the call, in milliseconds.

Infinity