Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): disable Worker wait loop for TS/N…
Browse files Browse the repository at this point in the history
…G parallel compilation in web containers

When using the `application` builder, a parallel TS/NG compilation is used that is run inside a Node.js Worker.
This Worker by default uses an Atomics-based wait loop to improve performance while waiting for messages. This
loop relies on the synchronous API `receiveMessageOnPort`. While this works well in Node.js, the web container
execution environment does not currently support passing transferable objects via `receiveMessageOnPort`. Attempting
to do so will cause a serialization error and a failed application build. To avoid this problem, the wait loop
optimization is disabled when the web container execution environment is detected. This change is only needed
for the TS/NG compilation as no other parallel operation within the build system currently uses `receiveMessageOnPort`
with transferable objects.

(cherry picked from commit 6f9ef1f)
  • Loading branch information
clydin authored and alan-agius4 committed Nov 8, 2023
1 parent 2152287 commit 1a5538e
Showing 1 changed file with 3 additions and 0 deletions.
Expand Up @@ -36,6 +36,9 @@ export class ParallelCompilation extends AngularCompilation {
minThreads: 1,
maxThreads: 1,
idleTimeout: Infinity,
// Web containers do not support transferable objects with receiveOnMessagePort which
// is used when the Atomics based wait loop is enable.
useAtomics: !process.versions.webcontainer,
filename: localRequire.resolve('./parallel-worker'),
});
}
Expand Down

0 comments on commit 1a5538e

Please sign in to comment.