From fc0d5c41212398ca7a391745c48f19c60c3685a5 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Tue, 17 May 2022 19:10:58 +0200 Subject: [PATCH] Release memory when unsubscribe fails Ensures that even when a call to the ethereum node to unsubscribe fails, it will release the memory associated with the subscription, including the subscription handler closure. --- ethers/providers/jsonrpc.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethers/providers/jsonrpc.nim b/ethers/providers/jsonrpc.nim index 5574ea9..256fcc6 100644 --- a/ethers/providers/jsonrpc.nim +++ b/ethers/providers/jsonrpc.nim @@ -158,9 +158,9 @@ method subscribe*(provider: JsonRpcProvider, method unsubscribe*(subscription: JsonRpcSubscription) {.async.} = let provider = subscription.provider + provider.subscriptions.del(subscription.id) let client = await provider.client discard await client.eth_unsubscribe(subscription.id) - provider.subscriptions.del(subscription.id) # Signer