diff --git a/.changeset/sour-guests-exercise.md b/.changeset/sour-guests-exercise.md new file mode 100644 index 00000000000..6138a786d95 --- /dev/null +++ b/.changeset/sour-guests-exercise.md @@ -0,0 +1,5 @@ +--- +"chainlink": patch +--- + +#internal additional logging to remote target capability diff --git a/core/capabilities/remote/target/request/client_request.go b/core/capabilities/remote/target/request/client_request.go index f1839ca8bdd..3952a2f7f64 100644 --- a/core/capabilities/remote/target/request/client_request.go +++ b/core/capabilities/remote/target/request/client_request.go @@ -127,6 +127,10 @@ func (c *ClientRequest) OnMessage(_ context.Context, msg *types.MessageBody) err c.mux.Lock() defer c.mux.Unlock() + if c.respSent { + return nil + } + if msg.Sender == nil { return fmt.Errorf("sender missing from message") } @@ -150,6 +154,10 @@ func (c *ClientRequest) OnMessage(_ context.Context, msg *types.MessageBody) err responseID := sha256.Sum256(msg.Payload) c.responseIDCount[responseID]++ + if len(c.responseIDCount) > 1 { + c.lggr.Warn("received multiple different responses for the same request, number of different responses received: %d", len(c.responseIDCount)) + } + if c.responseIDCount[responseID] == c.requiredIdenticalResponses { capabilityResponse, err := pb.UnmarshalCapabilityResponse(msg.Payload) if err != nil { @@ -159,6 +167,7 @@ func (c *ClientRequest) OnMessage(_ context.Context, msg *types.MessageBody) err } } } else { + c.lggr.Warnw("received error response", "error", msg.ErrorMsg) c.errorCount[msg.ErrorMsg]++ if c.errorCount[msg.ErrorMsg] == c.requiredIdenticalResponses { c.sendResponse(commoncap.CapabilityResponse{Err: errors.New(msg.ErrorMsg)}) diff --git a/core/capabilities/remote/target/request/server_request.go b/core/capabilities/remote/target/request/server_request.go index 0596374903b..b8ae05bc316 100644 --- a/core/capabilities/remote/target/request/server_request.go +++ b/core/capabilities/remote/target/request/server_request.go @@ -101,13 +101,11 @@ func (e *ServerRequest) Cancel(err types.Error, msg string) error { e.mux.Lock() defer e.mux.Unlock() - if e.hasResponse() { - return fmt.Errorf("request already has response") - } - - e.setError(err, msg) - if err := e.sendResponses(); err != nil { - return fmt.Errorf("failed to send responses: %w", err) + if !e.hasResponse() { + e.setError(err, msg) + if err := e.sendResponses(); err != nil { + return fmt.Errorf("failed to send responses: %w", err) + } } return nil