From 0322ae145105c726585587d383275b4046acb08b Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Tue, 27 Jun 2023 14:56:45 +0200 Subject: [PATCH] Ignore errors while polling --- ethers/providers/jsonrpc/subscriptions.nim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ethers/providers/jsonrpc/subscriptions.nim b/ethers/providers/jsonrpc/subscriptions.nim index c0e92c2..b13fb96 100644 --- a/ethers/providers/jsonrpc/subscriptions.nim +++ b/ethers/providers/jsonrpc/subscriptions.nim @@ -105,8 +105,14 @@ proc new*(_: type JsonRpcSubscriptions, let subscriptions = PollingSubscriptions(client: client) + proc getChanges(id: JsonNode): Future[JsonNode] {.async.} = + try: + return await subscriptions.client.eth_getFilterChanges(id) + except CatchableError: + return newJArray() + proc poll(id: JsonNode) {.async.} = - for change in await subscriptions.client.eth_getFilterChanges(id): + for change in await getChanges(id): if callback =? subscriptions.getCallback(id): callback(id, change)