Skip to content

Commit c433d4f

Browse files
committed
[executor] Do not cause executor disconnect on unprocessable MESSAGE
1 parent 936b352 commit c433d4f

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

executor/executor.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,10 @@ func buildEventHandler(state *internalState) events.Handler {
271271
Trace("received message data")
272272
err := handleMessageEvent(state, e.Message.Data)
273273
if err != nil {
274-
log.WithField("error", err.Error()).Debug("MESSAGE handler error")
274+
log.WithField("error", err.Error()).
275+
Debug("incoming MESSAGE handler error")
275276
}
276-
return err
277+
return nil // failed message handler (e.g. no such task) shouldn't cause an executor disconnect
277278
},
278279
executor.Event_SHUTDOWN: func(_ context.Context, e *executor.Event) error {
279280
log.WithField("event", e.Type.String()).Trace("handling event")

executor/handlers.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func handleMessageEvent(state *internalState, data []byte) (err error) {
116116
response.ErrorString = err.Error()
117117
}
118118

119-
data, marshalError := json.Marshal(response)
119+
jsonData, marshalError := json.Marshal(response)
120120
if marshalError != nil {
121121
if response.Err() != nil {
122122
log.WithFields(logrus.Fields{
@@ -137,7 +137,7 @@ func handleMessageEvent(state *internalState, data []byte) (err error) {
137137
return
138138
}
139139

140-
_, _ = state.cli.Send(context.TODO(), calls.NonStreaming(calls.Message(data)))
140+
_, _ = state.cli.Send(context.TODO(), calls.NonStreaming(calls.Message(jsonData)))
141141
if response.Err() != nil {
142142
log.WithFields(logrus.Fields{
143143
"commandName": response.GetCommandName(),
@@ -191,7 +191,7 @@ func handleMessageEvent(state *internalState, data []byte) (err error) {
191191

192192
response := activeTask.Transition(cmd)
193193

194-
data, marshalError := json.Marshal(response)
194+
jsonData, marshalError := json.Marshal(response)
195195
if marshalError != nil {
196196
if response.Err() != nil {
197197
log.WithFields(logrus.Fields{
@@ -212,7 +212,7 @@ func handleMessageEvent(state *internalState, data []byte) (err error) {
212212
return
213213
}
214214

215-
_, _ = state.cli.Send(context.TODO(), calls.NonStreaming(calls.Message(data)))
215+
_, _ = state.cli.Send(context.TODO(), calls.NonStreaming(calls.Message(jsonData)))
216216
if response.Err() != nil {
217217
log.WithFields(logrus.Fields{
218218
"commandName": response.GetCommandName(),

0 commit comments

Comments
 (0)