Skip to content

Commit 1ba4b2c

Browse files
committed
fix(jsonrpc): propagate cancelled error in call
- CancelledError was being swallowed by except CatchableError
1 parent 0f98528 commit 1ba4b2c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

ethers/providers/jsonrpc.nim

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,16 @@ proc new*(
8888
proc callImpl(
8989
client: RpcClient,
9090
call: string,
91-
args: JsonNode): Future[JsonNode] {.async: (raises: [JsonRpcProviderError]).} =
91+
args: JsonNode): Future[JsonNode] {.async: (raises: [CancelledError, JsonRpcProviderError]).} =
92+
93+
var response: JsonString
94+
try:
95+
response = await client.call(call, %args)
96+
except CancelledError as e:
97+
raise e
98+
except CatchableError as e:
99+
raiseJsonRpcProviderError e.msg
92100

93-
without response =? (await client.call(call, %args)).catch, error:
94-
raiseJsonRpcProviderError error.msg
95101
without json =? JsonNode.fromJson(response.string), error:
96102
raiseJsonRpcProviderError "Failed to parse response: " & error.msg
97103
json

0 commit comments

Comments
 (0)