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 getChanges(id):
if callback =? subscriptions.getCallback(id):
callback(id, change)
The code is basically correct, as should always return a JArray. A fix could e.g.:
proc poll(id: JsonNode) {.async.} =
let changes = await getChanges(id)
if changes.kind != JArray:
return
for change in changes:
if callback =? subscriptions.getCallback(id):
callback(id, change)
Alternatively, we could also modify the getChanges proc.
A similar issue were reported in the past for go-ethereum: https://github.com/ethereum/go-ethereum/issues/2746, but it should be resolved by now. Maybe somehow it propagated to HardHat and apparently on Windows only - I could not find any issue at Hardhat's GitHub.
On Windows when running tests, occasionally tests were failing with the following error:
the error is caused by
eth_getFilterChanges
occasionally returningJNull
instead ofJArray
on Windows.This is happening in vendor/nim-ethers/ethers/providers/jsonrpc/subscriptions.nim:
The code is basically correct, as should always return a
JArray
. A fix could e.g.:Alternatively, we could also modify the
getChanges
proc.A similar issue were reported in the past for go-ethereum: https://github.com/ethereum/go-ethereum/issues/2746, but it should be resolved by now. Maybe somehow it propagated to HardHat and apparently on Windows only - I could not find any issue at Hardhat's GitHub.