RPC API calls usually are cancelled too early such as
WARN [04-10|05:33:03.071] Served eth_getBlockByNumber conn=127.0.0.1:46600 reqid=1 t=262.386μs err="context canceled"
Also when cancelling the context for a call on a HTTP-based client while the call is running, the select in requestOp.wait may hit the <-context.Done() case instead of the <-op.resp case. This doesn't happen often -- our cancel test hasn't caught this even though it ran thousands of times on CI since the RPC client was added.
This PR makes sure to cancel the root context passed by RPC calls after all the requests are served and fix the rare deadlock when cancelling HTTP call context.
RPC API calls usually are cancelled too early such as
WARN [04-10|05:33:03.071] Served eth_getBlockByNumber conn=127.0.0.1:46600 reqid=1 t=262.386μs err="context canceled"
Also when cancelling the context for a call on a HTTP-based client while the call is running, the select inrequestOp.wait
may hit the<-context.Done()
case instead of the<-op.resp
case. This doesn't happen often -- our cancel test hasn't caught this even though it ran thousands of times on CI since the RPC client was added.This PR makes sure to cancel the root context passed by RPC calls after all the requests are served and fix the rare deadlock when cancelling HTTP call context.
Prerequisites:
References: