-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unhandled promise rejections en masse #1208
Comments
I don’t think this should affect anything, but can you try upgrading to the latest version of ethers? Does this just show up in the browser as unhandled? When using INFURA, alchemy, etc. are you including your own API key? |
The software runs on Node.js (not in the browser). And yes, the API keys being used are individuals' keys. We have a handful of people reporting this to happen for them, but it seems inconsistent insofar as others (including myself) do not run into the problem, even when running the same Docker image (from where the Node.js-based software is running). Upgrading to the latest ethers version was my next step. |
In my particular case, directly hitting the node(geth v1.9.25) from the container running the node.js application, using autocannon, there are no timeouts whatsoever:
Before, during, and after the test, the node.js application thrown lots of unhandled promise rejections. |
We did some more experimentation and it looks like increasing the polling interval is helping: Around ~75 errors per 5 minutes on the default (4000ms) Given that the block time is ~15s on mainnet, I wonder if |
I can reliably reproduce it with a script that does no more than: import { providers } from 'ethers'
async function run() {
const provider = new providers.InfuraProvider('mainnet', ...)
await provider.ready
for (const item of [ ...large array... ]) {
// create a transaction using `provider`
}
}
run() It always runs into the unresolved promise rejections, be it after 2, 5 or 10 minutes. |
I'm also getting this error, and I think #1221 is a duplicate of this one. ethers.js/packages/providers/src.ts/base-provider.ts Lines 588 to 621 in e0ccafb
On the code above, if |
Thanks! I will try to reproduce this today. Worst case I can add some code to force a poison (great word) with 50% probability to simulate the issue. :) |
Looks like #1084 is also this same bug. const checkInternalBlockNumber = resolveProperties({
blockNumber: this.perform("getBlockNumber", { }),
networkError: this.getNetwork(),
}).then(({ blockNumber }) => {
const respTime = getTime();
blockNumber = BigNumber.from(blockNumber).toNumber();
if (blockNumber < this._maxInternalBlockNumber) { blockNumber = this._maxInternalBlockNumber; }
this._maxInternalBlockNumber = blockNumber;
this._setFastBlockNumber(blockNumber); // @TODO: Still need this?
return { blockNumber, reqTime, respTime };
}).catch((error) => {
// Unremember this bad internal block number
if (this._internalBlockNumber === checkInternalBlockNumber) {
this._internalBlockNumber = null;
}
throw error;
}); |
Thanks for your hard work! I believe you are absolutely correct. I have made some local changes to reproduce this reliably (I added a new method used that will reject 50% of the time and succeed the other 50% of the time) and have a fix in place that I think works. I'll keep this ticket updated. |
This should be addressed in 5.0.26. Please try it out and let me know. :) |
@mrwillis The implemented fix doesn't prevent one error from happening: if your network is unstable or the eth node is overloaded, it can happen, and the best that can be done is to propagate and log, as is being done; the fix is actually to prevent one such error from never allowing further results to be properly fetched, which was the case before, and is fixed now; |
thanks @andrevmatos. What can be done on our end to avoid it bubbling up to the main scope? i.e., handling it somehow |
ethers 5.0.26 includes a fix for ethers-io/ethers.js#1208, which should remove the unresolved promise rejections we've seen in #183.
ethers 5.0.26 includes a fix for ethers-io/ethers.js#1208, which should remove the unresolved promise rejections we've seen in #183.
@mrwillis This seems to be a separate issue from the one 5.0.26 was intended to fix. I think I've found the problem though, and will fix it. |
Actually. I take that back. The promise I thought wasn't handled is. Are you possibly calling |
@ricmoo no not calling that. Could it be we are not awaiting |
@mrwillis Are you still having issues with this? |
@ricmoo All good now thanks |
ethers 5.0.26 includes a fix for ethers-io/ethers.js#1208, which should remove the unresolved promise rejections we've seen in #183.
ethers 5.0.26 includes a fix for ethers-io/ethers.js#1208, which should remove the unresolved promise rejections we've seen in #183.
We're seeing a ton of unhandled promise rejections using ethers 5.0.12:
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).
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.
The text was updated successfully, but these errors were encountered: