-
Notifications
You must be signed in to change notification settings - Fork 873
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
_handleServerNotification on Connection.ts has an unhandled error. #3053
Comments
Subscribe errors are caught here: https://github.com/solana-labs/solana-web3.js/blob/maintenance/v1.x/src/connection.ts#L6255-L6270 Unsubscribe errors are caught here: https://github.com/solana-labs/solana-web3.js/blob/maintenance/v1.x/src/connection.ts#L6310-L6322 In neither place are these errors surfaced to your application. It's possible that a check for All things considered, this subscriptions API and implementation are terminally flawed. We've completely rewritten it in 2.0, and I encourage you to migrate your app now. https://x.com/anza_xyz/status/1819093864394764674 |
Yes, in fact that is the problem, but I don't know how to solve it. If the program arrives to the line where is written I have modified
I have tried three different things without success:
Case 2. Add it to
Case 3. Add this piece of code in lines
Running the test
Running
Adding a
I will test it over a real server because I don't have the knowledge to do the test. By the way I think lines 6.297-6.299 are repeated and can be deleted: Using a totaly refactored library means investing lots of hours in learning how it works (take into account that there are not many examples published to use as reference), for a big project may have sense, for an small one may be it is faster to do your own small library instead of trying to learn how such a complex one works (talking from my ignorant point of view). Thank you. |
This in not working fine in my code, it just gives back
But even in that case, this code:
prints: |
My app uses connect.onAccountChange() and connect.removeAccountChangeListener() and is keeps open 100-200 subscritions.
Main libraries:
The app crashes when it tries to use subscribe/unsubscribe using onAccountChange()/removeAccountChangeListener() and the Websocket is not with readyState===1.
Fail when trying to subscribe (it goes in an infinite loop with all the accounts handled at that moment):
Fail when trying to unsubscribe (it goes in an infinite loop with all the accounts handled at that moment):
And finally crashes:
As far as WebSocket.readyState is not visible, I have tried to catch the error in different ways but I can't catch it.
Option 1: try-catch
Option 2: catch chained
These errors are in file "rpc-websocket.ts" call and notify reject funcions:
But I think the problem could came from 'connection.ts' which has this piece of code with a no controlled catch, because I can't catch the error:
Few questions open en Solana Stack Exchange:
https://solana.stackexchange.com/questions/15643/accountunsubscribe-and-accountsubscribe-error-tried-to-call-a-json-rpc-method-w
https://solana.stackexchange.com/questions/15698/solana-web3-js-it-is-not-possible-to-detect-websocket-error
Could it be a bug?
How can I handle or catch this error?
How can I check websocket.readyStatus to avoid subscribe/unsubscribe when it is not in OPEN or CONNECTING?
The text was updated successfully, but these errors were encountered: