From 09b2136b90e1d4b2b2f06c767516a7e8cd1f173f Mon Sep 17 00:00:00 2001 From: Colin Adler Date: Tue, 10 Jan 2023 00:16:35 -0600 Subject: [PATCH] fix: ignore EINVAL when fsyncing `/dev/stdout` Fixes: https://github.com/coder/coder/issues/5532 --- cli/scaletest.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cli/scaletest.go b/cli/scaletest.go index 7cda26e81..27a40b3ae 100644 --- a/cli/scaletest.go +++ b/cli/scaletest.go @@ -9,6 +9,7 @@ import ( "strconv" "strings" "sync" + "syscall" "time" "github.com/google/uuid" @@ -185,7 +186,9 @@ func (o *scaleTestOutput) write(res harness.Results, stdout io.Writer) error { // Sync the file to disk if it's a file. if s, ok := w.(interface{ Sync() error }); ok { err := s.Sync() - if err != nil { + // On Linux, EINVAL is returned when calling fsync on /dev/stdout. We + // can safely ignore this error. + if err != nil && !xerrors.Is(err, syscall.EINVAL) { return xerrors.Errorf("flush output file: %w", err) } }