fix(test): prevent batch-run scheduler from serializing after first wave#6
Open
crypticsaiyan wants to merge 1 commit into
Open
fix(test): prevent batch-run scheduler from serializing after first wave#6crypticsaiyan wants to merge 1 commit into
crypticsaiyan wants to merge 1 commit into
Conversation
create-batch --run launched its first concurrencyLimit triggers in parallel, but the steady-state loop awaited each subsequent job to fully finish (trigger + full --wait poll) before launching the next one. Effective concurrency dropped to 1 after the initial wave regardless of --max-concurrency. Switch to the launch-then-race pattern already used by the other three fan-outs in this file: launch up to the limit, relaunch on each completion via startNext(), never await a whole job inline. Add a regression test using equal-delay trigger responses so the first wave settles in the same microtask batch, which is the exact condition that exposed the bug.
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.
Summary
The
create-batch --runscheduler (runBatchRuninsrc/commands/test.ts) correctly launches the initialconcurrencyLimitjobs in parallel. However, the steady-state loop inadvertently awaits each subsequent job's full completion (both the trigger and the--waitpoll) before launching the next one.As a result, the effective concurrency drops to
1after the first wave completes, ignoring the--max-concurrencyflag for the remainder of the run.Note: 3 of the 4 fan-outs in this file already use the correct launch-then-relaunch pattern; this specific scheduler was the outlier.
The Fix
Replaced the blocking
drainOne()semaphore logic with a non-blockingstartNext()callback pattern.This removes the blocking
awaitthat was stalling thePromise.racequeue. It mirrors the implementation used by its siblingpollFreshAccepted, ensuring we launch up to the concurrency limit, immediately relaunch a new job into a slot as soon as one completes, and never block the scheduler on a single job's completion.Testing & Validation
Regression Test: Added a new test case in
src/commands/test.test.tsusing equal-delay mock responses.CI Gates: All local checks pass.
npm run lint&npm run format:checknpm run typechecknpm test(1448 tests passing)npm run test:coverage(≥80% threshold met)Files Changed:
src/commands/test.tssrc/commands/test.test.ts