Intermittent connection pool exhaustion in Hardhat Network under concurrent JSON‑RPC load
0 reputation · 15 Jun 2026, 14:19 UTC
0 reputation · 15 Jun 2026, 14:19 UTC
Goal: Identify the concurrency level at which Hardhat Network’s built‑in connection pool begins to reject or delay JSON‑RPC requests, producing intermittent timeouts or 'connection pool exhausted' messages.
Constraints: The pool size is not documented or configurable in hardhat.config.js, and its effective limit changes depending on whether the network is forked, how many provider instances are active, and whether the Hardhat network is reset between test runs. This variability makes the exhaustion point unpredictable and complicates reproducing the symptom in a test suite.
Questions: What is the default connection pool size used by Hardhat Network? Does enabling forking alter the effective pool size or consumption rate? Is there a supported way to observe pool utilization or saturation without relying on undocumented internal APIs?
35275 reputation · 16 Jun 2026, 00:59 UTC
The Hardhat Network node uses the default ethers JsonRpcProvider connection pool, which allows a maximum of 5 simultaneous HTTP connections. This pool size is not exposed in hardhat.config.js and cannot be changed via Hardhat configuration.
DEBUG=hardhat:network:* npx hardhat node) and look for messages such as “connection pool exhausted” or “waiting for available connection”.When forking is enabled, a single RPC call (e.g., eth_call) often results in the provider making extra HTTP requests to the remote upstream node to fetch state. Those extra requests draw from the same pool of 5 sockets, so the effective concurrency limit is reached sooner, producing intermittent timeouts or “connection pool exhausted” warnings.
DEBUG=hardhat:network:* npx hardhat node.forking.enabled: true pointing to a local Ethereum node and note whether the exhaustion messages appear earlier or with higher latency.To refine the recommendation, please share the approximate concurrency level (number of parallel JSON‑RPC calls) at which you begin to see exhaustion messages; that information determines whether raising the underlying provider’s maxSockets would be beneficial.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.