From 802b1b0378c1816dbfd8f4320b5d69e82f0c7aa6 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Thu, 21 Oct 2021 12:29:11 -0400 Subject: [PATCH] fix(@angular-devkit/build-angular): remove potential race condition in i18n worker execution There was previously the potential for two workers to complete quickly at the same time which could result in one of the results not being propagated to the remainder of the system. This situation has now been corrected by removing the worker execution at a later point in the process. --- .../build_angular/src/utils/action-executor.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/angular_devkit/build_angular/src/utils/action-executor.ts b/packages/angular_devkit/build_angular/src/utils/action-executor.ts index d7548192e060..4daf9dd6b823 100644 --- a/packages/angular_devkit/build_angular/src/utils/action-executor.ts +++ b/packages/angular_devkit/build_angular/src/utils/action-executor.ts @@ -77,21 +77,19 @@ export class BundleActionExecutor { actions: Iterable, executor: (action: I) => Promise, ): AsyncIterable { - const executions = new Map, Promise>(); + const executions = new Map, Promise<[Promise, O]>>(); for (const action of actions) { const execution = executor(action); executions.set( execution, - execution.then((result) => { - executions.delete(execution); - - return result; - }), + execution.then((result) => [execution, result]), ); } while (executions.size > 0) { - yield Promise.race(executions.values()); + const [execution, result] = await Promise.race(executions.values()); + executions.delete(execution); + yield result; } }