go io_error ai_generated true

write /dev/stdout: broken pipe

ID: go/io-copy-write-error

Also available as: JSON · Markdown · 中文
80%Fix Rate
82%Confidence
0Evidence
2024-04-22First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.21 active

Root Cause

Attempting to write to a closed or broken pipe, often when the reader (e.g., head command) exits early.

generic

中文

尝试写入已关闭或破裂的管道,通常当读取方(如 head 命令)提前退出时发生。

Workarounds

  1. 80% success
    _, err := io.Copy(dst, src); if err != nil { if errors.Is(err, syscall.EPIPE) { /* handle gracefully */ } else { log.Fatal(err) } }

Dead Ends

Common approaches that don't work:

  1. 90% fail

    The pipe remains broken; retries will fail repeatedly.

  2. 85% fail

    May hide critical I/O issues and lead to data loss.