Skip to content

Commit

Permalink
Handle output lines longer than 64 KiB
Browse files Browse the repository at this point in the history
This raises the limit to 100 MB. We buffer them in memory so we don't
want to make it unlimited.

Fixes #83.
  • Loading branch information
cespare committed Aug 27, 2021
1 parent 456b371 commit 13e5691
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion reflex.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,15 @@ func (r *Reflex) runCommand(name string, stdout chan<- OutMsg) {

go func() {
scanner := bufio.NewScanner(tty)
// Allow for lines up to 100 MB.
scanner.Buffer(nil, 100e6)
for scanner.Scan() {
stdout <- OutMsg{r.id, scanner.Text()}
}
// Intentionally ignoring scanner.Err() for now. Unfortunately,
if err := scanner.Err(); errors.Is(err, bufio.ErrTooLong) {
infoPrintln(r.id, "Error: subprocess emitted a line longer than 100 MB")
}
// Intentionally ignore other scanner errors. Unfortunately,
// the pty returns a read error when the child dies naturally,
// so I'm just going to ignore errors here unless I can find a
// better way to handle it.
Expand Down

0 comments on commit 13e5691

Please sign in to comment.