summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-13 09:53:49 +0300
committerPaul Buetow <paul@buetow.org>2026-05-13 09:53:49 +0300
commit54afec7ab8fc2d23d0aa8e4469536a683779620f (patch)
tree7ba0c8629d75d74e3b953a601e56f46c8950c0e1 /internal
parent83d68e56213c5107a4e24aceff61439c4e6644f4 (diff)
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 <noreply@anthropic.com>
Diffstat (limited to 'internal')
-rw-r--r--internal/flamegraph/iordata.go6
1 files changed, 5 insertions, 1 deletions
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))
+ }
}
}()