Conversation
|
The objective is to add an equivalent of this block of code: api/packages/rpc-provider/src/ws/index.ts Lines 450 to 456 in 12750bc We want to automatically reconnect when we disconnect. |
|
So it's not that simple. The problem to solve is not what to do when the health checker says that we're not healthy. The problem to solve is what to do when the connection to the extension dies. In other words, you should try to reconnect when an |
Im not sure why you refer to the extension. At the moment, When laptop goes to sleep and then resumes, the current code was cleaning up all subscriptions due to the emit of |
jacogr
left a comment
There was a problem hiding this comment.
It look sane. Happy to approve even if it only partly moves in the right direction.
|
This PR "seems" wrong to me. It would mean that the provider can report a I can't strictly say that this is wrong because it depends on the small details of the API of the Provider interface, and these small details aren't written anywhere. But it definitely feels wrong to me. |
|
The way I approached it, is that the subscription should be cleaned only if |
|
So the events handling would depend fully on the underlying layer. For instance in WS, when you get a disconnect, it would mean that the underlying transport is gone and dead, you will never receive anything on it again. In the WsProvider, after a network layer disconnect/re-connect, all subs that were existing re-created to ensure continuance. (Just continuing with the current ones will never have any data) So in this case, if a disconnect/reconnect means that the existing subs are still ongoing, it would be fine. If not, it would mean you have subscriptions that won't get any data back. |
|
The entire and only reason why we have this health checker system and why we generate disconnected and connected events is precisely to prevent PolkadotJS from querying information at certain moments. When we generate a "disconnected" event, we precisely mean "DO NOT USE THE CLIENT RIGHT NOW /!\ /!" It feels extremely surprising to me that subscriptions would stay alive during this mode. |
|
The ScProvider is currently behaving the same way as the WsProvider, and this PR makes the ScProvider more tolerant in an attempt to fix a problem somewhere. To me this indicates that this is not the correct fix. If things work fine with the WsProvider, and they do, then they should work fine with the ScProvider as well. And if necessary we should instead try to make the ScProvider behave more similarly to the WsProvider, rather than differently. |
|
Ok, read more, and the WsProvider re-subscribes: api/packages/rpc-provider/src/ws/index.ts Line 540 in 96a23bd I don't really understand why this is done in the WsProvider rather than a different layer, but this is what we should do in the ScProvider. |
jacogr
left a comment
There was a problem hiding this comment.
One small comment, looks sane otherwise.
It could make sense, now that there are 2 providers that require the same functionality, to extract resubscriptions - not for this PR, it would need investigation (could probably use an issue).
Co-authored-by: Jaco <jacogr@gmail.com>
As per your request: #5228 |
|
It's missing a |
|
It's also not clear to me why |
Because I'll fix the |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Resolves issue mentioned in substrate connect repo - issues #1243 and #1141