henrygd/beszel · error
close tmp: %w
Error message
close tmp: %w
What it means
Thrown by downloadFile when f.Close() fails after writing the temp file. Close flushes buffered data, so this typically indicates a delayed write error such as ENOSPC surfaced at close time, though it can also be an I/O error from the filesystem. The temp file is removed so no partial download remains.
Source
Thrown at agent/tools/fetchsmartctl/main.go:101
default:
f.Close()
os.Remove(tmp)
return fmt.Errorf("unsupported hash length: %d (expected 40 for SHA1 or 64 for SHA256)", len(cleanSha))
}
}
var mw io.Writer = f
if hasher != nil {
mw = io.MultiWriter(f, hasher)
}
if _, err := io.Copy(mw, resp.Body); err != nil {
f.Close()
os.Remove(tmp)
return fmt.Errorf("write tmp: %w", err)
}
if err := f.Close(); err != nil {
os.Remove(tmp)
return fmt.Errorf("close tmp: %w", err)
}
if hasher != nil && shaHex != "" {
cleanSha := strings.ToLower(strings.ReplaceAll(strings.TrimSpace(shaHex), " ", ""))
got := strings.ToLower(hex.EncodeToString(hasher.Sum(nil)))
if got != cleanSha {
os.Remove(tmp)
return fmt.Errorf("hash mismatch: got %s want %s", got, cleanSha)
}
}
// Make executable and move into place
if err := os.Chmod(tmp, 0o755); err != nil {
os.Remove(tmp)
return fmt.Errorf("chmod: %w", err)
}
if err := os.Rename(tmp, dest); err != nil {
os.Remove(tmp)View on GitHub (pinned to b38fb7dafa)
Solutions
- Check the wrapped %w OS error — usually ENOSPC or EIO
- Free disk space / raise quota and retry
- Verify the filesystem health (dmesg / smartctl on the build machine)
- Retry the download on a local disk instead of a network mount
Defensive patterns
Strategy: validation
Validate before calling
if err := syscall.Statfs(dir, &st); err == nil && uint64(st.Bavail)*uint64(st.Bsize) < minRequiredBytes {
return fmt.Errorf("insufficient free space in %s", dir)
} Try / catch
if err := downloadFile(url, dest, sha); err != nil {
if strings.HasPrefix(err.Error(), "close tmp:") {
fmt.Printf("disk/I-O problem on %s: %v — free space and retry\n", filepath.Dir(dest), err)
}
return err
} Prevention
- Keep ample headroom on the build volume (close() surfaces delayed ENOSPC)
- Avoid network filesystems as download destinations
- Monitor disk health (SMART) on build machines
- Clean partial .tmp artifacts after failed downloads
When it happens
Trigger: f.Close() returns non-nil after io.Copy succeeded — rare, usually deferred disk-full or I/O errors becoming visible only at flush/close.
Common situations: Disk filling exactly during the write; network filesystem reporting I/O errors on close; quota enforcement flushing at close.
Related errors
AI-assisted analysis of henrygd/beszel@b38fb7dafa (2026-08-31).
Data as JSON: /api/errors/82468bead2d5bbb5.
Report an issue: GitHub.