ethers.js: Unhandled promise rejections en masse
We’re seeing a ton of unhandled promise rejections using ethers 5.0.12:
Error: timeout (requestBody="{\"method\":\"eth_blockNumber\",\"params\":[],\"id\":52,\"jsonrpc\":\"2.0\"}", requestMethod="POST", timeout=120000, url="...snip...", code=TIMEOUT, version=web/5.0.11)
at Logger.makeError (/opt/indexer/node_modules/@ethersproject/logger/lib/index.js:179:21)
at Timeout._onTimeout (/opt/indexer/node_modules/@ethersproject/web/lib/index.js:148:35)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
The setup is as follows. After creating the Ethereum provider, we use it to make a number of contract calls and create transactions (as you would).
const ethereum = new providers.StaticJsonRpcProvider(
{
url: ...,
user: ...,
password: ...,
allowInsecureAuthentication: true,
},
"mainnet"
)
ethereum.pollingInterval = 4000
ethereum.on('debug', info => { ... })
ethereum.on('network', (newNetwork, oldNetwork) => {
logger.trace('Ethereum network change', {
oldNetwork: oldNetwork,
newNetwork: newNetwork,
})
})
logger.info(`Connected to Ethereum`, {
pollingInterval: ethereum.pollingInterval,
network: await ethereum.detectNetwork(),
})
We have tested custom Ethereum nodes, Alchemy, Infura — the behavior is the same across all of them. I’m not entirely sure what leads to the eth_blockNumber
calls, why they happen so frequently and why they all time out.
I’d be happy to provide more details if needed though.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 18 (7 by maintainers)
Commits related to this issue
- Fixed abundant UnhandledRejectErrors in provider polling (#1084, #1208, #1221, #1235). — committed to ethers-io/ethers.js by ricmoo 3 years ago
- Better provider internal block management (#1084, #1208, #1221, #1235). — committed to ethers-io/ethers.js by ricmoo 3 years ago
- *: Update ethers to 5.0.26 (#183) ethers 5.0.26 includes a fix for https://github.com/ethers-io/ethers.js/issues/1208, which should remove the unresolved promise rejections we've seen in #183. — committed to graphprotocol/indexer by Jannis 3 years ago
- *: Update ethers to 5.0.26 (#183) ethers 5.0.26 includes a fix for https://github.com/ethers-io/ethers.js/issues/1208, which should remove the unresolved promise rejections we've seen in #183. — committed to graphprotocol/indexer by Jannis 3 years ago
- *: Update ethers to 5.0.26 (#183) ethers 5.0.26 includes a fix for https://github.com/ethers-io/ethers.js/issues/1208, which should remove the unresolved promise rejections we've seen in #183. — committed to graphprotocol/indexer by Jannis 3 years ago
- *: Update ethers to 5.0.26 (#183) ethers 5.0.26 includes a fix for https://github.com/ethers-io/ethers.js/issues/1208, which should remove the unresolved promise rejections we've seen in #183. — committed to kingpig32/indexer by kingpig32 3 years ago
This should be addressed in 5.0.26. Please try it out and let me know. 😃