From 54afec7ab8fc2d23d0aa8e4469536a683779620f Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 13 May 2026 09:53:49 +0300 Subject: fix ignored file.Close error in iordata serialization error path On serialization failure the deferred close was called but its error silently discarded, potentially masking filesystem issues such as a full-disk condition detected only at close time. Capture the close error and join it with the existing retErr via errors.Join so callers see the full picture. Co-Authored-By: Claude Sonnet 4.6 --- internal/flamegraph/iordata.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'internal/flamegraph') diff --git a/internal/flamegraph/iordata.go b/internal/flamegraph/iordata.go index 36b5103..f67389a 100644 --- a/internal/flamegraph/iordata.go +++ b/internal/flamegraph/iordata.go @@ -112,8 +112,12 @@ func (iod *iorData) serializeToFile(flamegraphName string) (retErr error) { } defer func() { // Close file on error paths; on success it is already closed before rename. + // Capture the close error and join it with retErr so filesystem issues + // (e.g. full disk detected only on close) are not silently discarded. if retErr != nil { - file.Close() + if closeErr := file.Close(); closeErr != nil { + retErr = errors.Join(retErr, fmt.Errorf("close temp file %s: %w", tmpFilename, closeErr)) + } } }() -- cgit v1.2.3