fix(vitest): return early when queue batch is empty#135
Closed
pbomb wants to merge 1 commit into
Closed
Conversation
When Knapsack Pro queue mode exhausts its queue it signals agents by returning an empty array from the API. knapsack-pro-vitest was passing that empty array straight to startVitest(), which vitest treats as "no test files found" and exits with code 1. This marks the empty-batch call as green (no files = no failures) and skips the startVitest() invocation entirely, matching the expected queue-exhausted behaviour.
Contributor
|
I'm planning to review this week. Thanks 🙏 |
Contributor
|
The private fetchTestsFromQueue(...) {
this.knapsackProAPI
.fetchTestsFromQueue(...)
.then((response) => {
...
const isQueueEmpty = queueTestFiles.length === 0;
if (isQueueEmpty) {
this.finishQueueMode();
return;
}
onSuccess(queueTestFiles).then(So in the normal case this should not happen. But it could a problem with Fallback Mode. When Fallback Mode is triggered, there's another call to As soon as we confirm, I'd be happy to take care of the fix. |
Author
|
@3v0k4 This ended up not being the root cause. We were able to resolve our issue with the current release. I'm closing this PR. |
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
In queue mode, Knapsack Pro signals agents that the queue is exhausted by returning an empty array from the API.
knapsack-pro-vitestwas passing that empty array directly tostartVitest('test', [], ...).Vitest interprets an empty filter list as "no test files to run" and exits with code 1 (
"No test files found, exiting with code 1"). The package'sgetTestResultsfunction then readsprocess.exitCode !== 1to determineisTestSuiteGreen, so every agent that receives one or more empty batches marks the entire suite as failed — even when all actual tests passed.Fix
Return early from
onSuccesswith a green result whentestFilesis empty. This matches the expected queue-exhausted behaviour: no files assigned to this agent = no failures.Reproduction
Observed when using
KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILEwith a vitest workspace that usesprojects: [...]config. On a multi-agent run, agents that receive the queue-exhausted signal log"No test files found, exiting with code 1"and the overall suite is reported as failed despite all tests passing.Workaround currently in use:
--passWithNoTestsCLI flag (which makes vitest exit 0 for empty filter lists). That flag can be dropped once this fix is released.