diff --git a/runtime/runtime_single_client.go b/runtime/runtime_single_client.go index 31f76757..4918bf64 100644 --- a/runtime/runtime_single_client.go +++ b/runtime/runtime_single_client.go @@ -16,6 +16,7 @@ package runtime import ( + "errors" "fmt" "net" "strings" @@ -101,7 +102,17 @@ func (s *SingleRuntime) readFromSocket(command string) (string, error) { if err != nil { return "", err } - result := strings.TrimSuffix(data.String(), "\n> ") + + // Check that last 2 bytes are a LF, otherwise we received an incomplete response + results := data.String() + if len(results) > 2 { + if results[len(results)-2:] != "\n\n" { + err := errors.New("Incomplete read from socket") + return results, err + } + } + + result := strings.TrimSuffix(results, "\n> ") result = strings.TrimSuffix(result, "\n") return result, nil }