Skip to content

Commit

Permalink
Fix dependency cycle detection
Browse files Browse the repository at this point in the history
The way dependency cycles were detected no longer works now that activeTasks is populated early. Fix it.
  • Loading branch information
markw65 committed Apr 24, 2023
1 parent bcf8379 commit edde211
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,11 +524,6 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
}

private _executeTask(task: Task, resolver: ITaskResolver, trigger: string, encounteredDependencies: Set<string>, alreadyResolved?: Map<string, string>): Promise<ITaskSummary> {
if (encounteredDependencies.has(task.getCommonTaskId())) {
this._showDependencyCycleMessage(task);
return Promise.resolve({});
}

this._showTaskLoadErrors(task);

const mapKey = task.getMapKey();
Expand All @@ -540,15 +535,21 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
alreadyResolved = alreadyResolved ?? new Map<string, string>();
const promises: Promise<ITaskSummary>[] = [];
if (task.configurationProperties.dependsOn) {
encounteredDependencies.add(task.getCommonTaskId());
for (const dependency of task.configurationProperties.dependsOn) {
const dependencyTask = await resolver.resolve(dependency.uri, dependency.task!);
if (dependencyTask) {
this._adoptConfigurationForDependencyTask(dependencyTask, task);
const key = dependencyTask.getMapKey();
let promise = this._activeTasks[key] ? this._getDependencyPromise(this._activeTasks[key]) : undefined;
let promise;
if (encounteredDependencies.has(dependencyTask.getCommonTaskId())) {
this._showDependencyCycleMessage(dependencyTask);
promise = Promise.resolve({ exitCode: 1 });
} else {
promise = this._activeTasks[key] ? this._getDependencyPromise(this._activeTasks[key]) : undefined;
}
if (!promise) {
this._fireTaskEvent(TaskEvent.create(TaskEventKind.DependsOnStarted, task));
encounteredDependencies.add(task.getCommonTaskId());
promise = this._executeDependencyTask(dependencyTask, resolver, trigger, encounteredDependencies, alreadyResolved);
}
promises.push(promise);
Expand Down

0 comments on commit edde211

Please sign in to comment.