Fix issue with noop tasks that depend on other noop tasks#880
Open
dobesv wants to merge 2 commits intomicrosoft:masterfrom
Open
Fix issue with noop tasks that depend on other noop tasks#880dobesv wants to merge 2 commits intomicrosoft:masterfrom
dobesv wants to merge 2 commits intomicrosoft:masterfrom
Conversation
If you had a runnable task that depended on a noop task that in tern depended on a noop task, that depended on a runnable task, the dependency between the two runnable tasks would not be preserved. The logic that prunes out noop tasks in the dependency tree did not account for multiple levels of removal.
dobesv
commented
Oct 17, 2025
| for (const depId of node.dependencies) { | ||
| if (additionalDependencies.has(depId)) { | ||
| additionalDependencies.get(depId)!.forEach((subDepId) => newDependencies.add(subDepId)); | ||
| const newDependencies = new Set<string>(); |
Contributor
Author
There was a problem hiding this comment.
Note: there is a major performance issue in this algorithm that I have fixed in my own fork. If you're interested in this pull request I can update it with the fix. For now I'm assuming you're not going to do anything with this pull request so there's no need to fix it.
The fix:
// Update dependencies of remaining nodes
for (const node of nodeMap.values()) {
const newDependencies = new Set<string>();
const processedDeps = new Set<string>();
// Inherit the dependencies of removed nodes we depended on
const visitDependency = (depId: string) => {
if (processedDeps.has(depId)) {
return;
}
processedDeps.add(depId);
if (nodeMap.has(depId)) {
// It's still a valid node, keep in dependencies list
newDependencies.add(depId);
} else {
// Node was removed, propagate dependencies from the removed node
additionalDependencies.get(depId)?.forEach(visitDependency);
}
};
node.dependencies.forEach(visitDependency);
node.dependencies = Array.from(newDependencies);
}
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.
If you had a runnable task that depended on a noop task that in turn depended on a noop task, that depended on a runnable task, the dependency between the two runnable tasks would not be preserved. The logic that prunes out noop tasks in the dependency tree did not account for multiple levels of removal.