Skip to content

Commit 1a5538e

Browse files
clydinalan-agius4
authored andcommitted
fix(@angular-devkit/build-angular): disable Worker wait loop for TS/NG 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)
1 parent 2152287 commit 1a5538e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

packages/angular_devkit/build_angular/src/tools/esbuild/angular/compilation/parallel-compilation.ts

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ export class ParallelCompilation extends AngularCompilation {
3636
minThreads: 1,
3737
maxThreads: 1,
3838
idleTimeout: Infinity,
39+
// Web containers do not support transferable objects with receiveOnMessagePort which
40+
// is used when the Atomics based wait loop is enable.
41+
useAtomics: !process.versions.webcontainer,
3942
filename: localRequire.resolve('./parallel-worker'),
4043
});
4144
}

0 commit comments

Comments
 (0)