Skip to content

Fix executeConcurrent successCount when stopping on error - #18

Merged
CritasWang merged 1 commit into
apache:developfrom
PDGGK:fix/concurrent-executor-successcount
Jul 23, 2026
Merged

Fix executeConcurrent successCount when stopping on error#18
CritasWang merged 1 commit into
apache:developfrom
PDGGK:fix/concurrent-executor-successcount

Conversation

@PDGGK

@PDGGK PDGGK commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Problem

executeConcurrent(..., { stopOnError: true }) returns successCount: items.length - errors.length. When stopOnError trips, the worker loop stops and the remaining items are never attempted — they are neither successes nor failures, but the formula counts them all as successes (e.g. concurrency 1, first item throws → 0 operations complete, 1 error, but successCount === 9). A caller trusting successCount believes 9 operations succeeded when 9 were never attempted.

Fix

Return completedCount, which is incremented only after an operation resolves successfully. For the non-stopOnError paths completedCount === items.length - errors.length, so existing behavior is unchanged; only the stop-on-error case is corrected.

Tests

Added a regression case asserting successCount === 0 when the first item fails with stopOnError. Full tests/unit suite green (155 tests).

executeConcurrent reported successCount as `items.length - errors.length`.
When stopOnError trips, the remaining items are never attempted, yet this
formula counts every skipped item as a success (e.g. 10 items where the
first fails reports successCount 9 with 0 operations actually completed).

Use completedCount, which is incremented only after an operation resolves
successfully, and add a regression test.

Signed-off-by: Zihan Dai <99155080+PDGGK@users.noreply.github.com>
@CritasWang
CritasWang merged commit 0995073 into apache:develop Jul 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants