ethers.js
ethers.js copied to clipboard
Did the 'error' event listener get removed in v6, like provider.on('error', () => {})?
Ethers Version
6.2.3
Search Terms
No response
Describe the Problem
Did the 'error' event listener get removed in v6, like provider.on('error', () => {})?
Code Snippet
await provider.on('error', (error) => {
this.logger.error(`Connection error for chainId ${chainId}. Reconnecting...`, error);
setTimeout(() => this.setupProviderEvents(provider, chainId), 1000);
});
Contract ABI
No response
Errors
unhandledRejection TypeError: unknown ProviderEvent (argument="event", value="error", code=INVALID_ARGUMENT, version=6.3.0)
Environment
No response
Environment (Other)
No response
This seems to be similar and / or related to https://github.com/ethers-io/ethers.js/issues/3952
@ricmoo what happened to ProviderEvents? they seem all gone... (same behavior with 6.3.0)


This will be added in the next minor version. I'm currently trying to figure out the best way to abstract all the possible ways things can go wrong, so an extendable type can be provided for future internal errors.
This will be added in the next minor version. I'm currently trying to figure out the best way to abstract all the possible ways things can go wrong, so an extendable type can be provided for future internal errors.
Thank you, any workaround meanwhile? use window.ethereum.on?
Is there any update about this problem? I am still facing same issue.
It’s fixed in main, but not published yet. There are two small issues I want to include in the minor bump that fixes this. Should be published on npm soon.
These hidden errors are a real showstopper, is there anything I can help you with so that the release can be published? 🙂
I'm also concerned about this "error handling" for listeners, both for the high-level api and the low-level api:
https://github.com/ethers-io/ethers.js/blob/13593809bd61ef24c01d79de82563540d77098db/src.ts/contract/contract.ts#L583
https://github.com/ethers-io/ethers.js/blob/13593809bd61ef24c01d79de82563540d77098db/src.ts/providers/abstract-provider.ts#L1188
And especially this: https://github.com/ethers-io/ethers.js/blob/13593809bd61ef24c01d79de82563540d77098db/src.ts/providers/subscriber-filterid.ts#L97
I simulate a serious problem by restarting my hardhat test network. Then the whole application gets stuck and there is no way to recover from this bogus state:
@TODO TypeError: results is not iterable
at FilterIdEventSubscriber._emitResults (/Users/xxx/node_modules/ethers/src.ts/providers/subscriber-filterid.ts:159:30)
at FilterIdEventSubscriber.#poll (/Users/xxx/node_modules/ethers/src.ts/providers/subscriber-filterid.ts:96:24)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Errors are silently catched everywhere and there is also no global error event listener that could be used to reset the connection.
Event after updating to v6.4.0 the issue is still there
I’ll look into this in the morning.
Is this still pending?
Did you fix?