fix(core): schedule tasks and release waiting threads when continuous task is already running (#30673)

## Current Behavior

When a continuous task is already running, parent tasks are not
scheduled.

## Expected Behavior

When a continuous task is already running, the task orchestrator should
schedule the next tasks and release the waiting threads so parent tasks
can be scheduled.

## Related Issue(s)

Fixes #
This commit is contained in:
Leosvel Pérez Espinosa 2025-04-10 20:27:40 +02:00 committed by Jason Jean
parent 48a5d1987e
commit a1cd4e31ad

View File

@ -629,7 +629,11 @@ export class TaskOrchestrator {
async startContinuousTask(task: Task, groupId: number) {
if (this.runningTasksService.getRunningTasks([task.id]).length) {
// task is already running, we need to poll and wait for the running task to finish
// task is already running by another process, we schedule the next tasks
// and release the threads
await this.scheduleNextTasksAndReleaseThreads();
// wait for the running task to finish
do {
console.log(`Waiting for ${task.id} in another nx process`);
await new Promise((resolve) => setTimeout(resolve, 100));
@ -697,10 +701,7 @@ export class TaskOrchestrator {
) {
await childProcess.getResults();
} else {
await this.tasksSchedule.scheduleNextTasks();
// release blocked threads
this.waitingForTasks.forEach((f) => f(null));
this.waitingForTasks.length = 0;
await this.scheduleNextTasksAndReleaseThreads();
}
return childProcess;
@ -797,6 +798,10 @@ export class TaskOrchestrator {
})
);
await this.scheduleNextTasksAndReleaseThreads();
}
private async scheduleNextTasksAndReleaseThreads() {
await this.tasksSchedule.scheduleNextTasks();
// release blocked threads