fix(test): dedupe and serialize chunked batch-rerun dispatch#9
Open
crypticsaiyan wants to merge 1 commit into
Open
fix(test): dedupe and serialize chunked batch-rerun dispatch#9crypticsaiyan wants to merge 1 commit into
crypticsaiyan wants to merge 1 commit into
Conversation
Batch-rerun chunks (>50 testIds) were dispatched concurrently via Promise.all. The backend's producer/teardown closure dedup happens per-request, not across requests, so two concurrent chunks sharing a project's producer could each independently decide to trigger it, double-running the producer or teardown. Dispatch chunks sequentially in both the initial and deferred-retry paths, closing the race at the source. Also dedupe the aggregated accepted[] by testId and merge closure.byProject across chunks as a defensive second layer, warning on stderr if a duplicate trigger is detected. Fixed a pre-existing test whose fixture relied on the old double-counting behavior (same accepted entry returned from every retry call).
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
Previously, running
test rerun --allwould split requests into chunks of 50 tests and dispatch all chunks concurrently usingPromise.all. However, the backend's producer/teardown deduplication logic operates within a single request, not across concurrent requests. If two tests in different chunks shared a project's producer or teardown, the backend would independently decide "not yet triggered" for both, causing the shared dependency to execute multiple times.Note: This concurrent dispatch bug applied to both the initial batch dispatch and the deferred-retry loop.
The Fix
Implemented sequential chunk dispatch and a client-side deduplication defense layer to prevent double-execution:
Promise.allwith sequential execution (oneawaitper chunk). By the time chunk N is sent, chunk N-1 has already landed server-side, allowing the backend to correctly deduplicate shared dependencies against the previous chunk.dedupeBatchRerunAcceptedto drop duplicatetestIdentries from the aggregatedacceptedlist, andmergeBatchRerunClosureByProjectto safely mergeclosure.byProjectentries without double-counting. The CLI now emits a warning tostderrif it detects and filters out a duplicate trigger.D3: batch rerun summary...) that was artificially relying on the old double-counting bug.Testing & Validation
Regression Test: Added new test cases in
src/commands/test.rerun.spec.tsto verify serialization and deduplication.stderrwarning.CI Gates: All local checks pass.
npm run lint&npm run format:checknpm run typechecknpm test(1449 tests passing)npm run test:coverage(≥80% threshold met; actual ~87%)Files Changed:
src/commands/test.tssrc/commands/test.rerun.spec.ts