cancel context before waiting for waitgroup to avoid deadlock in RPC on error (#5345)

Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
This commit is contained in:
ledgerwatch 2022-09-13 02:52:58 +01:00 committed by GitHub
parent bbea37a454
commit 9ff5b21a1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -241,8 +241,8 @@ func (h *handler) handleMsg(msg *jsonrpcMessage, stream *jsoniter.Stream) {
// call goroutines to shut down.
func (h *handler) close(err error, inflightReq *requestOp) {
h.cancelAllRequests(err, inflightReq)
h.callWG.Wait()
h.cancelRoot()
h.callWG.Wait()
h.cancelServerSubscriptions(err)
}