From 619a7e825e36ff50e07211c39d8da6b70a848b51 Mon Sep 17 00:00:00 2001 From: Denis Frenademetz Date: Fri, 11 Feb 2022 21:23:34 +0100 Subject: [PATCH] fix(core): wait for tasks to be scheduled before checking for work (#8840) Ensure task are scheduled before checking if there is some work to do, else it can occur that tasks are scheduled, but no check for work is triggered until the next task completes. Closes #8888. --- packages/workspace/src/tasks-runner/task-orchestrator.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/workspace/src/tasks-runner/task-orchestrator.ts b/packages/workspace/src/tasks-runner/task-orchestrator.ts index 5334e43e31..24ea9c2d71 100644 --- a/packages/workspace/src/tasks-runner/task-orchestrator.ts +++ b/packages/workspace/src/tasks-runner/task-orchestrator.ts @@ -384,6 +384,10 @@ export class TaskOrchestrator { ); await this.tasksSchedule.scheduleNextTasks(); + + // release blocked threads + this.waitingForTasks.forEach((f) => f(null)); + this.waitingForTasks.length = 0; } private complete( @@ -408,9 +412,6 @@ export class TaskOrchestrator { ); } } - this.waitingForTasks // release blocked threads - .forEach((f) => f(null)); - this.waitingForTasks.length = 0; } //endregion Lifecycle