This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a set of proposed changes to fix the 4 issues with unsubscribe which are described in issue 2669.
Motivation
The goal of these changes is to ensure that eth_unsubscribe is called properly every time a subscription is ended, either via SubscriptionStream::drop or SubscriptionStream::unsubscribe().
Solution
This fixes a json-rpc formatting issue, an issue of translating subscription ID from client-side to server-side ID, and issues of simply not calling eth_unsubscribe in the IPC and ws-legacy PubsubClients.
I tried to keep these changes to a minimal set which would fix these issues and avoid any breaking changes. There's some remaining weirdness in that the boolean return value from eth_unsubscribe indicating success is not plumbed through ethers to the caller. Doing so complicates things as it requires await-ing the response, and the unsubscribe code is used in non-async contexts including pinned SubscriptionStream::drop(), which isn't easily modified to call async functions. If we want to plumb the return value, I can make additional changes to do so, but I suspect it would either require some code duplication or trickery which may not be worthwhile.
PR Checklist