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

LightClient: Unsubscribe from subscriptions to avoid warnings #1402

Closed
lexnv opened this issue Jan 26, 2024 · 0 comments · Fixed by #1408
Closed

LightClient: Unsubscribe from subscriptions to avoid warnings #1402

lexnv opened this issue Jan 26, 2024 · 0 comments · Fixed by #1408
Assignees

Comments

@lexnv
Copy link
Collaborator

lexnv commented Jan 26, 2024

The unstable-light-client feature does not unsubscribe from subscriptions.
This behavior leads to subscriptions living forever.

In the context of the chainHead this could be detrimental and could lead in the future to users not being able to subscribe anymore. This is because the chainHead spec states that at least 2 subscriptions should be supported by the server per connection.

This has been tested locally with the: #1400

test light_client::light_client_testing has been running for over 60 seconds
2024-01-26T13:44:24.492595Z  WARN subxt-light-client-background: Subscription response id=1 chain=ChainId(0) is not tracked
2024-01-26T13:44:30.816682Z  WARN subxt-light-client-background: Subscription response id=1 chain=ChainId(0) is not tracked
2024-01-26T13:44:36.269689Z  WARN subxt-light-client-background: Subscription response id=1 chain=ChainId(0) is not tracked
2024-01-26T13:44:42.308706Z  WARN subxt-light-client-background: Subscription response id=1 chain=ChainId(0) is not tracked
2024-01-26T13:44:48.451372Z  WARN subxt-light-client-background: Subscription response id=1 chain=ChainId(0) is not tracked
2024-01-26T13:44:48.616638Z  WARN subxt-light-client-background: Subscription response id=1 chain=ChainId(0) is not tracked
2024-01-26T13:44:54.568271Z  WARN subxt-light-client-background: Subscription response id=1 chain=ChainId(0) is not tracked
2024-01-26T13:45:00.501182Z  WARN subxt-light-client-background: Subscription response id=1 chain=ChainId(0) is not tracked

In the following code, the RPC unsubscribe method name is ignored:

fn subscribe_raw<'a>(
&'a self,
sub: &'a str,
params: Option<Box<RawValue>>,
_unsub: &'a str,

To mitigate this extend the background protocol to utilize the unsubscribe method.
Whenever the user drops the subscription in the frontend, the backend should initiate a call to the unsubscribe_method.
Because the request to the unsubscribe_method does not have a frontend user associated with; its response should be logged and dropped.

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 a pull request may close this issue.

1 participant