Skip to content

Commit

Permalink
Fix batchCallBuffer timeout handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan-Wilson committed Feb 28, 2023
1 parent 3e96f97 commit 5061259
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions rpc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,14 @@ func (b *batchCallBuffer) timeout(ctx context.Context, conn jsonWriter) {
for _, msg := range b.calls {
if !msg.isNotification() {
resp := msg.errorResponse(&internalServerError{errcodeTimeout, errMsgTimeout})
b.resp = append(b.resp, resp)
serialized, err := json.Marshal(resp)
if err != nil {
conn.writeJSON(ctx, errorMessage(&parseError{"error serializing timeout error: " + err.Error()}), true)
b.wrote = true
return
}

b.resp = append(b.resp, serialized)
}
}
b.doWrite(ctx, conn, true)
Expand Down Expand Up @@ -243,7 +250,7 @@ func (h *handler) handleBatch(msgs []*jsonrpcMessage) {
resp := h.handleCallMsg(cp, msg)
err := callBuffer.pushResponse(resp)
if err != nil {
h.conn.writeJSON(cp.ctx, errorMessage(err))
h.conn.writeJSON(cp.ctx, errorMessage(err), true)
return
}
}
Expand Down

0 comments on commit 5061259

Please sign in to comment.