Skip to content

Commit d9e8193

Browse files
clydinalan-agius4
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. (cherry picked from commit 802b1b0)
1 parent 082b08f commit d9e8193

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,19 @@ export class BundleActionExecutor {
4747
actions: Iterable<I>,
4848
executor: (action: I) => Promise<O>,
4949
): AsyncIterable<O> {
50-
const executions = new Map<Promise<O>, Promise<O>>();
50+
const executions = new Map<Promise<O>, Promise<[Promise<O>, O]>>();
5151
for (const action of actions) {
5252
const execution = executor(action);
5353
executions.set(
5454
execution,
55-
execution.then((result) => {
56-
executions.delete(execution);
57-
58-
return result;
59-
}),
55+
execution.then((result) => [execution, result]),
6056
);
6157
}
6258

6359
while (executions.size > 0) {
64-
yield Promise.race(executions.values());
60+
const [execution, result] = await Promise.race(executions.values());
61+
executions.delete(execution);
62+
yield result;
6563
}
6664
}
6765

0 commit comments

Comments
 (0)