From 770c97e5f1fcf7c055f3b2209da4a544358de9e8 Mon Sep 17 00:00:00 2001 From: Vasyl Ivanchuk Date: Wed, 30 Oct 2024 19:27:03 +0200 Subject: [PATCH] fix: json rpc provider timeout config (#302) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # What ❔ Fix JSON RPC Provider timeout configuration. ## Why ❔ This was overlooked when the explorer was migrated from an old SDK with ethers v5 to a new SDK with ethers v6. ## Checklist - [X] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [X] Tests for the changes have been added / updated. --- .../src/rpcProvider/jsonRpcProviderExtended.ts | 7 ++++++- packages/worker/src/rpcProvider/jsonRpcProviderExtended.ts | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/data-fetcher/src/rpcProvider/jsonRpcProviderExtended.ts b/packages/data-fetcher/src/rpcProvider/jsonRpcProviderExtended.ts index 4c1510b5b..356ff0677 100644 --- a/packages/data-fetcher/src/rpcProvider/jsonRpcProviderExtended.ts +++ b/packages/data-fetcher/src/rpcProvider/jsonRpcProviderExtended.ts @@ -1,4 +1,5 @@ import { Provider } from "zksync-ethers"; +import { FetchRequest } from "ethers"; import { ProviderState, JsonRpcProviderBase } from "./jsonRpcProviderBase"; import logger from "../logger"; @@ -18,13 +19,17 @@ export class JsonRpcProviderExtended extends Provider implements JsonRpcProvider batchMaxSizeBytes: number, batchStallTimeMs: number ) { - super(providerUrl, undefined, { + const fetchRequest = new FetchRequest(providerUrl); + fetchRequest.timeout = connectionTimeout; + + super(fetchRequest, undefined, { timeout: connectionTimeout, batchMaxSize: batchMaxSizeBytes, batchMaxCount: batchMaxCount, staticNetwork: true, batchStallTime: batchStallTimeMs, }); + this.connectionQuickTimeout = connectionQuickTimeout; } diff --git a/packages/worker/src/rpcProvider/jsonRpcProviderExtended.ts b/packages/worker/src/rpcProvider/jsonRpcProviderExtended.ts index 4c1510b5b..356ff0677 100644 --- a/packages/worker/src/rpcProvider/jsonRpcProviderExtended.ts +++ b/packages/worker/src/rpcProvider/jsonRpcProviderExtended.ts @@ -1,4 +1,5 @@ import { Provider } from "zksync-ethers"; +import { FetchRequest } from "ethers"; import { ProviderState, JsonRpcProviderBase } from "./jsonRpcProviderBase"; import logger from "../logger"; @@ -18,13 +19,17 @@ export class JsonRpcProviderExtended extends Provider implements JsonRpcProvider batchMaxSizeBytes: number, batchStallTimeMs: number ) { - super(providerUrl, undefined, { + const fetchRequest = new FetchRequest(providerUrl); + fetchRequest.timeout = connectionTimeout; + + super(fetchRequest, undefined, { timeout: connectionTimeout, batchMaxSize: batchMaxSizeBytes, batchMaxCount: batchMaxCount, staticNetwork: true, batchStallTime: batchStallTimeMs, }); + this.connectionQuickTimeout = connectionQuickTimeout; }