fix(core): fix env for running parallel tasks (#27889)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->
- 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
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes https://github.com/nrwl/nx/issues/27586
This commit is contained in:
Emily Xiong 2024-09-17 15:15:30 -04:00 committed by GitHub
parent cf1ffdea00
commit adc1abd003
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;