-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Infinite loop in web3.js subscription handling #26665
Comments
If I'm almost positive that this is because of corruption in Tracked in #25578. |
Oh, I see what you're saying. Yeah, that's a leak. Not sure if it's the one that's causing your problem, but a leak. |
FWIW when I changed my code to keep an active subscription (ie never go to
-no subscriptions- and hence start the disconnect), I haven’t had the
problem. Before it was happening every few hours, and now not at all for a
few days.
On Fri, 22 Jul 2022 at 18:16, Steven Luscher ***@***.***> wrote:
Oh, I see what you're saying. Yeah, that's a leak. Not sure if it's the
one that's causing your problem, but a leak.
—
Reply to this email directly, view it on GitHub
<#26665 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACVTZ5TJMZYJ63VQZF6FN3VVJKENANCNFSM535Z2YRQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
Sent from Gmail Mobile
|
I landed this change. If you have time to update to the version after 1.50.0 and retest your app, @yamen, I'd love to hear if this fixed things for you. |
Thanks Steve I will check in a week or so, temporary workaround is stable for now so will wait for regular dependency update chore. |
We are currently on 1.52 (https://github.com/solana-labs/solana-web3.js/releases/tag/v1.52.0) and we are still experiencing this issue. We never get more than 3 to 5 subscriptions. We actively track and unsubscribe from the wallets every X minutes. When this occurs, we hit 99% cpu usage and our gateway locks up. |
I have a situation where I have a handful of subscriptions, and my WebSocket temporarily disconnects. This will sometimes cause an infinite loop with 300k errors in the logs of the type:
slotSubscribe error for argument [] WebSocket is not open: readyState 0 (CONNECTING)
Before an eventually out of memory error and process crash.
From looking at the code, there seems to be a potential edge case race condition. Namely:
_updateSubscriptions()
is called when there are no active subscriptions and an active connection._rpcWebSocketConnected = false
and starts a 500ms timer to actually disconnect the WebSocket:solana/web3.js/src/connection.ts
Lines 4543 to 4556 in c4d2c95
_updateSubscriptions()
is called again. Now there are active subscriptions and no active connection._rpcWebSocketConnected = true
:solana/web3.js/src/connection.ts
Lines 4561 to 4565 in c4d2c95
_updateSubscriptions()
as the normal guards to stop this from happening have been bypassed:_rpcWebSocketConnected = true
even though we're not really connected, which stops the function from returning early_rpcWebSocketGeneration
doesn't get updated as there isn't a newclose
event since entering the functionNow the WebSocket calls fail (hence the error), but the failure leads to an infinite recursion of trying again and again on loop.
I think this is what's happening, very hard to debug. Using a different flag for a 'pending disconnect' scenario will likely fix this.
The text was updated successfully, but these errors were encountered: