Skip to content

Commit

Permalink
fix: json rpc provider timeout config (#302)
Browse files Browse the repository at this point in the history
# 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

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [X] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [X] Tests for the changes have been added / updated.
  • Loading branch information
vasyl-ivanchuk authored Oct 30, 2024
1 parent 1388956 commit 770c97e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Provider } from "zksync-ethers";
import { FetchRequest } from "ethers";
import { ProviderState, JsonRpcProviderBase } from "./jsonRpcProviderBase";
import logger from "../logger";

Expand All @@ -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;
}

Expand Down
7 changes: 6 additions & 1 deletion packages/worker/src/rpcProvider/jsonRpcProviderExtended.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Provider } from "zksync-ethers";
import { FetchRequest } from "ethers";
import { ProviderState, JsonRpcProviderBase } from "./jsonRpcProviderBase";
import logger from "../logger";

Expand All @@ -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;
}

Expand Down

0 comments on commit 770c97e

Please sign in to comment.