Skip to content

go.unhandled_error_goroutine

Stability High

Detects errors not handled in goroutines.

Unhandled errors in goroutines:

  • Silent failures - Errors are lost without logging
  • Debugging difficulty - No trace of what went wrong
  • Inconsistent state - Failed operations go unnoticed
// ❌ Before (error silently ignored)
go func() {
result, err := processData(data)
if err != nil {
return // Error is lost!
}
// use result
}()
// ✅ After (error properly handled)
go func() {
result, err := processData(data)
if err != nil {
log.Printf("processData failed: %v", err)
errorChan <- err
return
}
resultChan <- result
}()
// ✅ Alternative (with error group)
g, ctx := errgroup.WithContext(ctx)
g.Go(func() error {
return processData(ctx, data)
})
if err := g.Wait(); err != nil {
log.Printf("goroutine failed: %v", err)
}
  • Error returns ignored in goroutines
  • Missing error logging in goroutines
  • Goroutines swallowing errors silently

Unfault can add error logging or channel-based error propagation patterns.