-
-
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
uncaughtException when instantiating JsonRpcProvider and adding subscription in bad network conditions #3924
Comments
I found the problem, which was in the poll loop of the PollingBlockSubscriber; when it crashed it threw and failed to re-schedule the next poll. You still won't be able to get the error in the try block, since the In the next minor bump, I'll add an But I think for your purposes, just "not crashing" is your main concern. :) You won't get any block events until the network conditions have improved; but once the link is back up, you will get all previous blocks backfilled. Make sense? |
(also, huge thanks for providing a concise example to reproduce against ;)) |
This should be fixed in v6.2.1. Let me know if you have any feedback. And I'll add the Thanks! |
@ricmoo incredible thank you for turning this around so quickly! the error emitter sounds great and yes for now not crashing is our main concern :) |
Hello, I'd like to reopen this issue, specifically regarding this comment:
This is not always desirable, and I don't think it's 100% right to assume that if a node is stopped, it wasn't on purpose. I thought this was originally an issue with Hardhat, so I opened this issue here: NomicFoundation/hardhat#4358 that has a bit more details on my specific use case and why it can be problematic. Is there any way to clear this "cache" safely? Or workaround? I wasn't sure if it was appropriate to reopen this, so let me know if I should open a new issue. |
@antoinedc If you don't want the events backfilled, you can use I should add documentation for this use-case though, as it isn't obvious the |
Ah I see, thanks. However, when should I call that? When I stop the node, the provider doesn't seem to emit an 'error' event, so I can't put it in there. |
Ethers Version
6.2.0
Search Terms
No response
Describe the Problem
When instantiating a JsonRpcProvider and setting up a listener, an thrown exception is thrown if the rpc url returns a bad status code and there doesn't seem to be any way to catch it.
https://replit.com/@deodad/Ethers-Uncaught-Exception?v=1
Code Snippet
Contract ABI
No response
Errors
No response
Environment
node.js (v12 or newer)
Environment (Other)
No response
The text was updated successfully, but these errors were encountered: