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.
  • Loading branch information
clydin authored and filipesilva committed Oct 22, 2021
1 parent 2decc2d commit 802b1b0
Showing 1 changed file with 5 additions and 7 deletions.
Expand Up @@ -77,21 +77,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 802b1b0

Please sign in to comment.