diff --git a/pkg/stack/stackdump.go b/pkg/stack/stackdump.go index 36bbbf5383..7506b0c256 100644 --- a/pkg/stack/stackdump.go +++ b/pkg/stack/stackdump.go @@ -30,8 +30,10 @@ func DumpToFile(dir string) (string, error) { if err != nil { return "", errors.Wrap(err, "failed to open file to write the goroutine stacks") } - defer f.Close() - defer f.Sync() + defer func() { + _ = f.Sync() + _ = f.Close() + }() } else { f = os.Stderr }