Skip to content

Commit 802b1b0

Browse files
clydinfilipesilva
authored andcommitted
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.
1 parent 2decc2d commit 802b1b0

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

packages/angular_devkit/build_angular/src/utils/action-executor.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,19 @@ export class BundleActionExecutor {
7777
actions: Iterable<I>,
7878
executor: (action: I) => Promise<O>,
7979
): AsyncIterable<O> {
80-
const executions = new Map<Promise<O>, Promise<O>>();
80+
const executions = new Map<Promise<O>, Promise<[Promise<O>, O]>>();
8181
for (const action of actions) {
8282
const execution = executor(action);
8383
executions.set(
8484
execution,
85-
execution.then((result) => {
86-
executions.delete(execution);
87-
88-
return result;
89-
}),
85+
execution.then((result) => [execution, result]),
9086
);
9187
}
9288

9389
while (executions.size > 0) {
94-
yield Promise.race(executions.values());
90+
const [execution, result] = await Promise.race(executions.values());
91+
executions.delete(execution);
92+
yield result;
9593
}
9694
}
9795

0 commit comments

Comments
 (0)