# panic: sync: WaitGroup is reused before previous Wait has returned

- **ID:** `go/waitgroup-wait-race`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A WaitGroup was reused (Add called) while a previous Wait() had not yet returned, which is explicitly disallowed by the sync package.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.18 | active | — | — |
| 1.22 | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   for _, batch := range batches {
    var wg sync.WaitGroup
    for _, it := range batch {
        wg.Add(1)
        go func(it Item) { defer wg.Done(); process(it) }(it)
    }
    wg.Wait()
}
   ```
2. **** (92% success)
   ```
   for _, stage := range stages {
    g := new(errgroup.Group)
    for _, t := range stage { g.Go(t.Run) }
    if err := g.Wait(); err != nil { return err }
}
   ```

## Dead Ends

- **** — Recover leaves the WaitGroup in an inconsistent state and the concurrent Wait may return early or hang. (85% fail)
- **** — Two Waits on the same group do not resolve the reuse race; it can still panic. (80% fail)
- **** — Timing-based, non-deterministic, and fails under load. (90% fail)
