Skip to content
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

Clear the reconnection timer when the socket reconnects for any reason #138

Merged
merged 1 commit into from
Feb 23, 2023
Merged

Clear the reconnection timer when the socket reconnects for any reason #138

merged 1 commit into from
Feb 23, 2023

Conversation

steveluscher
Copy link
Contributor

@steveluscher steveluscher commented Feb 23, 2023

It's quite possible for a caller to invoke connect() on the Client while it's in the midst of counting down to a reconnect. This will result in the reconnection clobbering the explicit connection attempt, and corrupting the internal state of the Client.

This change cancels the reconnection attempt when such an explicit reconnection is ordered.

Fixes solana-labs/solana-web3.js#1106

It's quite possible for a caller to invoke `connect()` on the `Client` while it's in the midst of counting down to a reconnect. This change cancels the reconnection attempt when such an explicit reconnection is ordered.
@steveluscher
Copy link
Contributor Author

How does this strike you, @mkozjak? I'm all yours, this week, to help get this in. If you don't have time, just let me know and I'll proceed to fork rpc-websockets or use patch-package in the meantime.

@jpablogn
Copy link

jpablogn commented Jul 30, 2024

I use these libraries:
@solana/web3.js 1.73.3
rpc-websockets 7.5.1

If I use connection.onAccountChange or connection.removeOnAccountListener and websocket is not in ready state, I have this error:

accountUnsubscribe error: Tried to call a JSON-RPC method accountUnsubscribe but the socket was not CONNECTING or OPEN (readyState was 2)

I can't control websocket state because it is not an accesible variable.

I have tried to catch the error without success:
https://solana.stackexchange.com/questions/15643/accountunsubscribe-and-accountsubscribe-error-tried-to-call-a-json-rpc-method-w

Any suggestion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[web3.js] Infinite recursion caused by _updateSubscriptions
3 participants