conc icon indicating copy to clipboard operation
conc copied to clipboard

fix: collect results after last error in ResultErrorPool

Open Yanhu007 opened this issue 7 months ago • 0 comments

Fixes #156

Problem

ResultErrorPool.Wait() drops all results that come after the last errored task:

p := pool.NewWithResults[int]().WithErrors().WithMaxGoroutines(1)
p.Go(func() (int, error) { return 1, nil })
p.Go(func() (int, error) { return 2, errors.New("err") })
p.Go(func() (int, error) { return 3, nil })

got, _ := p.Wait()
// Got:    [1]
// Expect: [1, 3]

The collect method's filtering loop appends segments between errored indices but never appends the tail segment after the last error.

Fix

Append the tail segment (results[lastErrored+1:]) after the loop.

Regression test added.

All existing tests pass.

Yanhu007 avatar Apr 15 '26 08:04 Yanhu007