-
Couldn't load subscription status.
- Fork 305
fix(insights): use web3.js Connection instead of PythConnection #3158
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
Conversation
Upon investigation, it seems the `PythConnection` from `@pythnetwork/client` is extremely inefficient for a few reasons: 1. `PythConnection` requires loading _all_ account info when creating the connection class, so that it can build a mapping from price account to program account. However IH never used this mapping in practice, so all of that was wasted work. This caused major issues for page load performance as loading all account info from pythnet was a ton of parsing which locked up the browser for multiple seconds. 2. `PythConnection` did not expose a mechanism to remove unused subscriptions In doing this I also removed all the live prices contexts since none of that is needed any more, as well as the call to initialize prices with the last available price as that too looks unnecessary and redundant. This change should _drastically_ improve performance in IH, especially during page load.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
| ); | ||
| return () => { | ||
| removeSubscription(feedKey, setData); | ||
| unsubscribe(cluster, subscriptionId).catch((error: unknown) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: should we consider a failure to unsubscrive as a more critical failure and alert the user to reload their page (or similar)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, at the worst case it means that the websocket will be continuing to send some data that we ignore. The way the web3.js Connection object works is that it updates all subscriptions when creating a new subscription or deleting a subscription, so the websocket unsubscribe message will be retried by the next time any change in the subscribed feeds happens anyways. So even the problem with continuing to receive unnecessary ws messages would resolve itself by just navigating around the app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.

Upon investigation, it seems the
PythConnectionfrom@pythnetwork/clientis extremely inefficient for a few reasons:PythConnectionrequires loading all account info when creating the connection class, so that it can build a mapping from price account to program account. However IH never used this mapping in practice, so all of that was wasted work. This caused major issues for page load performance as loading all account info from pythnet was a ton of parsing which locked up the browser for multiple seconds.PythConnectiondid not expose a mechanism to remove unused subscriptionsIn doing this I also removed all the live prices contexts since none of that is needed any more, as well as the call to initialize prices with the last available price as that too looks unnecessary and redundant.
This change should drastically improve performance in IH, especially during page load.