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

- **ID:** `go/panic-sync-waitgroup-is-reused-before-previous-wait-has-re`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

wg.Add() is called again while a previous wg.Wait() is still in progress, which is explicitly disallowed by the WaitGroup contract.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.18 | active | — | — |
| 1.20 | active | — | — |
| 1.23 | active | — | — |

## Workarounds

1. **** (93% success)
   ```
   Create a fresh WaitGroup per batch: do not reuse the same wg across phases. var wg sync.WaitGroup once per logical group of goroutines.
   ```
2. **** (90% success)
   ```
   Use golang.org/x/sync/errgroup where lifecycle is bounded by Wait() returning, and never call Go() after Wait() has been invoked.
   ```

## Dead Ends

- **** — The mutex serializes the calls but does not change the illegal reuse pattern; the panic still fires. (85% fail)
- **** — A naive channel close races with still-running goroutines and may close early, producing send-on-closed panics. (70% fail)
