Skip to content

Commit 13e5691

Browse files
committed
Handle output lines longer than 64 KiB
This raises the limit to 100 MB. We buffer them in memory so we don't want to make it unlimited. Fixes #83.
1 parent 456b371 commit 13e5691

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

reflex.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,15 @@ func (r *Reflex) runCommand(name string, stdout chan<- OutMsg) {
287287

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

0 commit comments

Comments
 (0)