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.
This commit is contained in:
Eric 2024-10-23 17:59:28 +11:00
parent 507ac6a4cc
commit 05fdb0605e
No known key found for this signature in database
1 changed files with 10 additions and 1 deletions

View File

@ -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