Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src.ts/providers/abstract-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ export class AbstractProvider implements Provider {

#disableCcipRead: boolean;

#ccipReadFetchTimeout: number;

#options: Required<AbstractProviderOptions>;

/**
Expand Down Expand Up @@ -503,6 +505,7 @@ export class AbstractProvider implements Provider {
this.#timers = new Map();

this.#disableCcipRead = false;
this.#ccipReadFetchTimeout = 0;
}

get pollingInterval(): number { return this.#options.pollingInterval; }
Expand Down Expand Up @@ -545,6 +548,18 @@ export class AbstractProvider implements Provider {
get disableCcipRead(): boolean { return this.#disableCcipRead; }
set disableCcipRead(value: boolean) { this.#disableCcipRead = !!value; }

/**
* The timeout (in milliseconds) for each CCIP-read fetch request.
* If set to a value greater than 0, this overrides the default
* FetchRequest timeout for CCIP operations. A value of ``0`` uses
* the default timeout.
*/
get ccipReadFetchTimeout(): number { return this.#ccipReadFetchTimeout; }
set ccipReadFetchTimeout(timeout: number) {
assertArgument(timeout >= 0, "timeout must be non-negative", "timeout", timeout);
this.#ccipReadFetchTimeout = timeout;
}

// Shares multiple identical requests made during the same 250ms
async #perform<T = any>(req: PerformActionRequest): Promise<T> {
const timeout = this.#options.cacheTimeout;
Expand Down Expand Up @@ -600,6 +615,10 @@ export class AbstractProvider implements Provider {
request.body = { data, sender };
}

if (this.#ccipReadFetchTimeout > 0) {
request.timeout = this.#ccipReadFetchTimeout;
}

this.emit("debug", { action: "sendCcipReadFetchRequest", request, index: i, urls });

let errorMessage = "unknown error";
Expand Down