Skip to content

Commit

Permalink
tryfix: err no log
Browse files Browse the repository at this point in the history
  • Loading branch information
JingYiJun committed May 24, 2024
1 parent d55cea0 commit 226890b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
7 changes: 4 additions & 3 deletions apis/record/yocsef.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ func InferYocsefAsyncAPI(c *websocket.Conn) {
// listen to interrupt and connection close
go func() {
defer cancel(errors.New("client connection closed or interrupt"))
_, _, err := c.ReadMessage()
if err != nil {
_, _, innerErr := c.ReadMessage()
if innerErr != nil {
return
}
}()

record, err := service.InferYocsef(
var record *DirectRecord
record, err = service.InferYocsef(
ctx,
c,
body.Request,
Expand Down
9 changes: 4 additions & 5 deletions service/yocsef.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@ func InferYocsef(
var detectedOutput string

for {
line, err := reader.ReadBytes('\n')
var line []byte
line, err = reader.ReadBytes('\n')
if errors.Is(err, io.EOF) {
break
}
if err != nil {
return nil, err
}

line = bytes.Trim(line, " \n\r")
if strings.HasPrefix(string(line), "event") {
continue
Expand Down Expand Up @@ -126,14 +128,11 @@ func InferYocsef(
}
detectedOutput = before

err = w.WriteJSON(InferResponseModel{
_ = w.WriteJSON(InferResponseModel{
Status: 1,
Output: nowOutput,
Stage: "MOSS",
})
if err != nil {
return nil, err
}
}

if ctx.Err() != nil {
Expand Down

0 comments on commit 226890b

Please sign in to comment.