Skip to content

Commit

Permalink
fix scan error on too long line (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwinger233 authored Dec 4, 2020
1 parent ed12e37 commit 7f2f209
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,12 +807,25 @@ func (v *Vibranium) RunAndWait(stream pb.CoreRPC_RunAndWaitServer) error {
}
}
}()
scanner := bufio.NewScanner(r)
for scanner.Scan() {
log.Infof("[Async RunAndWait] %v", scanner.Text())
}
if err := scanner.Err(); err != nil {
log.Errorf("Async RunAndWait] scan error: %v", err)
bufReader := bufio.NewReader(r)
for {
var (
line, part []byte
isPrefix bool
err error
)
for {
if part, isPrefix, err = bufReader.ReadLine(); err != nil {
log.Errorf("[Aysnc RunAndWait] read error: %+v", err)
return
}
line = append(line, part...)
if !isPrefix {
break
}

}
log.Infof("[Async RunAndWait] %s", line)
}
})
}()
Expand Down

0 comments on commit 7f2f209

Please sign in to comment.