Skip to content

Commit 8a0966d

Browse files
authored
rpc: improve check on Context-Cancellation not using string compare (#19445)
closes #8676 Verified that the software already filters for Context-Cancellation errors; however, one of the checks is currently based on the error string rather than the error type
1 parent ac47b8f commit 8a0966d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

rpc/handler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"bytes"
2424
"context"
2525
"encoding/json"
26+
"errors"
2627
"fmt"
2728
"reflect"
2829
"slices"
@@ -517,7 +518,7 @@ func (h *handler) handleCallMsg(ctx *callProc, msg *jsonrpcMessage, stream jsons
517518
}
518519
}
519520

520-
if resp != nil && resp.Error != nil && resp.Error.Message != "context canceled" {
521+
if resp != nil && resp.Error != nil && !errors.Is(ctx.ctx.Err(), context.Canceled) {
521522
if resp.Error.Data != nil {
522523
h.logger.Warn("[rpc] served", "method", msg.Method, "reqid", idForLog(msg.ID),
523524
"err", resp.Error.Message, "errdata", resp.Error.Data)

0 commit comments

Comments
 (0)