go runtime_error ai_generated true

error: goroutine leak detected (channel send blocked)

ID: go/goroutine-leak-channel-block

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

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.19 active
1.22 active

Root Cause

A goroutine is blocked sending to a channel that no other goroutine reads from.

generic

中文

goroutine在向通道发送数据时阻塞,因为没有其他goroutine从该通道读取。

Workarounds

  1. 95% success
    go func() { ch <- data }(); result := <-ch
  2. 90% success
    select { case ch <- data: default: /* handle timeout */ }

Dead Ends

Common approaches that don't work:

  1. 60% fail

    Only postpones the problem; buffer fills up eventually.

  2. 90% fail

    Sleep does not fix the root cause; may cause indefinite blocking.