From adc1abd00350105b75c084a01b801e9ff9ba299c Mon Sep 17 00:00:00 2001 From: Emily Xiong Date: Tue, 17 Sep 2024 15:15:30 -0400 Subject: [PATCH] fix(core): fix env for running parallel tasks (#27889) ## Current Behavior - between this.tasksSchedule.scheduleNextTasks() and this.tasksSchedule.nextTask(), scheduledTasks are different when in parallel, so when calling `processAllScheduledTasks`, it does not process the all scheduled tasks, so it did not populate env. ## Expected Behavior ## Related Issue(s) Fixes https://github.com/nrwl/nx/issues/27586 --- packages/nx/src/tasks-runner/task-orchestrator.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/nx/src/tasks-runner/task-orchestrator.ts b/packages/nx/src/tasks-runner/task-orchestrator.ts index f481936abd3ad..f10700ac54079 100644 --- a/packages/nx/src/tasks-runner/task-orchestrator.ts +++ b/packages/nx/src/tasks-runner/task-orchestrator.ts @@ -82,7 +82,7 @@ export class TaskOrchestrator { ]); // initial scheduling - await this.scheduleNextTasks(); + await this.tasksSchedule.scheduleNextTasks(); performance.mark('task-execution:start'); @@ -118,6 +118,7 @@ export class TaskOrchestrator { this.options.skipNxCache === false || this.options.skipNxCache === undefined; + this.processAllScheduledTasks(); const batch = this.tasksSchedule.nextBatch(); if (batch) { const groupId = this.closeGroup(); @@ -615,19 +616,13 @@ export class TaskOrchestrator { }) ); - await this.scheduleNextTasks(); + await this.tasksSchedule.scheduleNextTasks(); // release blocked threads this.waitingForTasks.forEach((f) => f(null)); this.waitingForTasks.length = 0; } - private async scheduleNextTasks() { - await this.tasksSchedule.scheduleNextTasks(); - - this.processAllScheduledTasks(); - } - private complete( taskResults: { taskId: string;