Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SassWorkerImplementation relies on analytics interval for the process to be kept alive in some environments #20985

Closed
leosvelperez opened this issue May 28, 2021 · 1 comment · Fixed by #21045
Labels
Milestone

Comments

@leosvelperez
Copy link
Contributor

leosvelperez commented May 28, 2021

The recently added SassWorkerImplementation in 12.0.1, when it creates a worker, immediately calls unref() on it as seen here. This can cause the process to exit too early (before the worker gets to receive any message) in certain scenarios where there are no other handles (CI environments, Docker builds, etc). The reason this is currently working in those environments is because there's an interval running to flush the analytics while the build is running (command-runner.ts#L252), which keeps the event loop busy and prevents the process from exiting.

Relying on that interval to keep the process alive is not ideal. I'm not sure if that was intentional or not, but this could lead to the SASS implementation unexpectedly being broken if that interval is removed in the future, with hard to debug issues and no apparent reason for it to break since the change might seem unrelated.

This issue did appear on Nx workspaces since Nx runs the builders directly (by mimicking what Angular CLI does except the analytics part) and it doesn't go through the command runner, therefore no interval was running and the process was exiting without producing any build artifact (repro: nrwl/nx#5729 (comment) and workaround: nrwl/nx#5807).

I did confirm in the Angular CLI code that by removing the analytics interval, the issue would arise. By removing the calls to unref() everything works fine and the process exits normally when the compilation is finished or errored.

@alan-agius4 alan-agius4 added area: @angular-devkit/build-angular freq1: low Only reported by a handful of users who observe it rarely labels May 31, 2021
@ngbot ngbot bot added this to the Backlog milestone May 31, 2021
clydin added a commit to clydin/angular-cli that referenced this issue Jun 3, 2021
…Webpack shutdown

Sass Worker instances and resource requests are now cleaned up when the Webpack compiler is shutdown. This removes the need to unreference the workers upon creation.

Fixes angular#20985
clydin added a commit to clydin/angular-cli that referenced this issue Jun 3, 2021
…Webpack shutdown

Sass Worker instances and resource requests are now cleaned up when the Webpack compiler is shutdown. This removes the need to unreference the workers upon creation.

Fixes angular#20985
alan-agius4 pushed a commit that referenced this issue Jun 4, 2021
…Webpack shutdown

Sass Worker instances and resource requests are now cleaned up when the Webpack compiler is shutdown. This removes the need to unreference the workers upon creation.

Fixes #20985

(cherry picked from commit 1dd5c28)
alan-agius4 pushed a commit that referenced this issue Jun 4, 2021
…Webpack shutdown

Sass Worker instances and resource requests are now cleaned up when the Webpack compiler is shutdown. This removes the need to unreference the workers upon creation.

Fixes #20985
@angular-automatic-lock-bot
Copy link

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 Jul 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
3 participants