From 05fdb0605e1e0d4e76bcd25152f3b50189321ccc Mon Sep 17 00:00:00 2001 From: Eric <5089238+emizzle@users.noreply.github.com> Date: Wed, 23 Oct 2024 17:59:28 +1100 Subject: [PATCH] fix: modify unsubscribe cleanup routine Ignore exceptions (other than CancelledError) if uninstallation of the filter fails. If it's the last step in the subscription cleanup, then filter changes for this filter will no longer be polled so if the filter continues to live on in geth for whatever reason, then it doesn't matter. --- ethers/providers/jsonrpc/subscriptions.nim | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ethers/providers/jsonrpc/subscriptions.nim b/ethers/providers/jsonrpc/subscriptions.nim index e2bc6cb..6567f3b 100644 --- a/ethers/providers/jsonrpc/subscriptions.nim +++ b/ethers/providers/jsonrpc/subscriptions.nim @@ -218,7 +218,16 @@ method subscribeLogs(subscriptions: PollingSubscriptions, method unsubscribe*(subscriptions: PollingSubscriptions, id: JsonNode) {.async.} = - discard await subscriptions.client.eth_uninstallFilter(subscriptions.subscriptionMapping[id]) subscriptions.filters.del(id) subscriptions.callbacks.del(id) subscriptions.subscriptionMapping.del(id) + try: + discard await subscriptions.client.eth_uninstallFilter(subscriptions.subscriptionMapping[id]) + except CancelledError as e: + raise e + except CatchableError as e: + # Ignore if uninstallation of the filter fails. If it's the last step in our + # cleanup, then filter changes for this filter will no longer be polled so + # if the filter continues to live on in geth for whatever reason then it + # doesn't matter. + discard