-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
bugVerified to be an issue.Verified to be an issue.fixed/completeThis Bug is fixed or Enhancement is complete and published.This Bug is fixed or Enhancement is complete and published.v6Issues regarding v6Issues regarding v6
Description
Ethers Version
Search Terms
JsonRpcProvider, pollingInterval
Describe the Problem
The pollingInterval option of JsonRpcProvider is not used for transaction wait(), instead a default 4000 ms value is used.
It may be linked to the pollingInterval value being hardcoded in the constructor.
ethers.js/src.ts/providers/provider-jsonrpc.ts
Line 1165 in ad5f1c5
| this.#pollingInterval = 4000; |
this fix in provider-jsonrpc.ts seems to do the trick but I did not check the other impacts:
export class JsonRpcApiPollingProvider extends JsonRpcApiProvider {
#pollingInterval;
constructor(network, options) {
super(network, options);
this.#pollingInterval = options.pollingInterval ?? 4000; // use option when it exists
}Also I'm not sure why 4000 is hardcoded as the value is available in defaultOptions.pollingInterval
Code Snippet
import { JsonRpcProvider, Wallet } from "ethers";
// The following snippet can be tested on a hardhat or anvil node with a 1s blocktime.
const provider = new JsonRpcProvider("http://localhost:8545", undefined, {
pollingInterval: 1000,
});
const wallet = new Wallet(process.env.PRIVATE_KEY).connect(provider);
console.log("provider.pollingInterval", provider.pollingInterval);
// provider.pollingInterval 4000
console.log(
'provider._getOption("pollingInterval")',
provider._getOption("pollingInterval")
);
// provider._getOption("pollingInterval") 1000
const tx = await wallet.sendTransaction({ to: wallet.address, data: "0x" });
console.time("tx");
await tx.wait();
console.timeEnd("tx");
// tx: 4.094sContract ABI
No response
Errors
No response
Environment
No response
Environment (Other)
No response
Metadata
Metadata
Assignees
Labels
bugVerified to be an issue.Verified to be an issue.fixed/completeThis Bug is fixed or Enhancement is complete and published.This Bug is fixed or Enhancement is complete and published.v6Issues regarding v6Issues regarding v6