-
-
Notifications
You must be signed in to change notification settings - Fork 876
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
bug: WebSocket auto reconnect is not supported #877
Comments
Definitely on the todo. Open for contributions here. |
Can I take this? |
Sure |
Hiya, @sb-saksham if you need any help, or an additional pair of eyes, drop me a message... |
Yes @0xRapid I rewrite the function for reconnection and was writing the test cases would be great if you have a look
I ran the test suite and all the previously written test for webSocket was passing(rpc.test.ts file's tests were passed) now I need to write the test cases for this code |
Hiya @sb-saksham However, there should be multiple parameters that have a default value but can be passed by the user.
Also, |
I have implemented all the functionality as advised (Here's the commit) but I cannot complete the tests( It would be great if you could go through the environment setup with me once. Or any diagnostic you could suggest this is
I forced stopped the |
maybe @jxom can assist with that |
@sb-saksham |
@sb-saksham managed to get it working? |
Yes! But one test is failing! I have submitted a pull request as I mentioned earlier. Here it is #989 |
@jxom :( |
The docs should mention this, lest someone rely on websockets in production |
… when the connection drops This will be reversed when viem supports auto reconnecting websockets - wevm/viem#877
Are there any updates on this? It seems the previous PR has gone stale and been closed. It seems that it's straightforward to create a new connection on error but the more difficult part is ensuring that you re-subscribe to all of the subscriptions. Is that correct? I would be willing to take a stab on this but I'd need some guidance on how to determine what are the outstanding subscriptions and how to re-subscribe. |
Latest PR for this issue: #1894 |
What is the status on this? This is super critical for production. |
Fixed via 212eab2. Will be in next release. |
This issue has been locked since it has been closed for more than 14 days. If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Viem version. If you have any questions or comments you can create a new discussion thread. |
Is there an existing issue for this?
Package Version
1.2.13
Current Behavior
When using watchBlocks or any other type of watch (subscription). When something happens to the network or any connectivity issues happen and is restored, the WebSocket does not perform an auto reconnect when it is stable again.
Expected Behavior
WebSocket tries to reconnect every X interval based on reconnect options
Steps To Reproduce
The best way to reproduce it is by disabling your network adapter and enabling it after 2seconds and see if you get new block headers again.
Link to Minimal Reproducible Example (StackBlitz, CodeSandbox, GitHub repo etc.)
No response
Anything else?
isomorphic-ws uses base JS websocket API behind the scenes Link
From what I dug, I saw that viem currently only adds event listeners for
close
andmessage
. LinkFirst, I think that all of the event listeners should be added in order to give the user more functionality over what's happening, besides that, I believe that with an error event listener, we could possibly implement an auto reconnect inside viem itself.
Reference:
web3js: Link
The text was updated successfully, but these errors were encountered: