Skip to content

fix(@angular-devkit/build-angular): disable Worker wait loop for TS/NG parallel compilation in web containers#26265

Merged
alan-agius4 merged 2 commits intoangular:mainfrom
clydin:esbuild/no-atomics-web-containers
Nov 8, 2023
Merged

fix(@angular-devkit/build-angular): disable Worker wait loop for TS/NG parallel compilation in web containers#26265
alan-agius4 merged 2 commits intoangular:mainfrom
clydin:esbuild/no-atomics-web-containers

Conversation

@clydin
Copy link
Copy Markdown
Member

@clydin clydin commented Nov 7, 2023

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.

…mpilation inside WebContainers"

This reverts commit 421c175.
…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.
@clydin clydin force-pushed the esbuild/no-atomics-web-containers branch from f256076 to d84f04d Compare November 7, 2023 20:17
@clydin clydin added the action: merge The PR is ready for merge by the caretaker label Nov 7, 2023
@alan-agius4 alan-agius4 added target: patch This PR is targeted for the next patch release and removed action: merge The PR is ready for merge by the caretaker labels Nov 8, 2023
@d3lm
Copy link
Copy Markdown
Contributor

d3lm commented Nov 8, 2023

Just to add some extra color here: I have tested the build with parallel compilation enabled and atomic loop disabled and it seems to work well in Chrome for both initial build and re-compilation. In Firefox the initial build also seems to work now, but it still gets stuck on re-compilation, but not always. Sometimes it worked. I am still trying to understand what's going on here. But at least the initial build now seems to work in Firefox as well.

@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Nov 8, 2023
@ngbot
Copy link
Copy Markdown

ngbot bot commented Nov 8, 2023

I see that you just added the action: merge label, but the following checks are still failing:
    failure status "mergeability" is failing
If you want your PR to be merged, it has to pass all the CI checks.
If you can't get the PR to a green state due to flakes or broken main, please try rebasing to main and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@alan-agius4 alan-agius4 merged commit 6f9ef1f into angular:main Nov 8, 2023
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants