Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): remove potential race condition i…
Browse files Browse the repository at this point in the history
…n 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.

(cherry picked from commit 802b1b0)
(cherry picked from commit d9e8193)
  • Loading branch information
clydin authored and alan-agius4 committed Nov 2, 2021
1 parent 1d8cdf8 commit 4168441
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,19 @@ export class BundleActionExecutor {
actions: Iterable<I>,
executor: (action: I) => Promise<O>,
): AsyncIterable<O> {
const executions = new Map<Promise<O>, Promise<O>>();
const executions = new Map<Promise<O>, Promise<[Promise<O>, 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;
}
}

Expand Down

0 comments on commit 4168441

Please sign in to comment.