Fix executeConcurrent successCount when stopping on error - #18
Merged
CritasWang merged 1 commit intoJul 23, 2026
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
executeConcurrent(..., { stopOnError: true })returnssuccessCount: items.length - errors.length. WhenstopOnErrortrips, 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, butsuccessCount === 9). A caller trustingsuccessCountbelieves 9 operations succeeded when 9 were never attempted.Fix
Return
completedCount, which is incremented only after an operation resolves successfully. For the non-stopOnError pathscompletedCount === items.length - errors.length, so existing behavior is unchanged; only the stop-on-error case is corrected.Tests
Added a regression case asserting
successCount === 0when the first item fails withstopOnError. Fulltests/unitsuite green (155 tests).