-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Build doesn't generate artifacts with @angular-devkit/build-angular@12.0.1 #5729
Comments
I want to follow up on this ticket as it should maybe be marked as a bug. I am building multiples SPAs with this command in my CI build: Until a few days ago, this ran flawlessly. Now, it builds only ~5 of the SPAs. Here's what the log has to say:
If I go directly in to the build and execute the same command to see if I can build the SPA myself, I get:
But the SPA does not exist in ./dist/apps and nothing gets built. The build just skips several of my SPAs. Project info:
|
yes, i am having exactly the same issue. the builds are not done at all. |
I have the same issue. It works fine with version 12.1.0. Stopped working after upgrade to 12.3.4. |
Having the same issue and trying to narrow it down. Has anyone found some hints on it? |
+1 to this issue. Works fine on mac but nothing builds on linux. |
We've got a similar issue. Build works perfectly on Windows & WSL(2) but produces no output in our GitLab CI with no errors (even without any caches) |
That's really weird... If I run But if I remove from Dockerfile line with build (only |
After some research I found that my project stopped building after update angular to 12.0.1. On angular 12.0.0 it seems to work. Could anyone else confirm that? |
@gmisiolek I'm working my way downward. Am on 12.3.0 now. Every clean build takes 3 hours so it's a bit slow to say the least. Wondering if I go down to 12.0.0, that I'll get other errors now that Angular 12 is final. Looking at 12.0.1, there were no big changes that would affect the cache. |
If I remember correctly, my CI build has been running flawlessly until a week ago so I do think this was a recent regression error. |
@bjornharvold but I managed to make it work with nx 12.3.4 and @angular/* 12.0.0 |
I can confirm that angular 12.0.1 is indeed the issue. Downgrading our workspace to angular 12.0.0 is building correctly in CI (linux based). Running locally on my mac both versions of angular build correctly.
|
After further testing it looks like upgrade I've updated all @angular/* packages to 12.0.1, except this one and it looks like everything works fine. |
I can confirm @gmisiolek observation. 12.0.0 runs with |
@jredl-va But which version of @angular/* libs do you have? Especially |
Builds fine. 12.0.1 is confirmed as broken. It appears this breakage only occurs on linux based machines. |
Hey all, the reason it is happening is because we have a new optimization where when the dist already exists, we don't copy files when tasks are cached. However, this means that if there's another step that mutates the dist, then the original result of the cache would be lost. We'll take a look at this issue and see what we can do about it. @leosvelperez please take a look at this issue. |
@FrozenPandaz but in my case |
Yes, I can confirm that it is indeed @angular-devkit/build-angular@12.0.1 that is the culprit. |
Hey all, as @FrozenPandaz said, we introduced an optimization to prevent copying files when they are supposed to be there already. As an FYI, the following is the logic to decide whether to retrieve the output from the cache or not:
So, if the output doesn't exist, it should retrieve it from the cache as it seems, from the comments in this thread, to be happening in Windows and MacOS. I tried to reproduce the issue in a Docker container with Ubuntu but I've failed to reproduce it so far. I'm gonna need some reproduction steps so I can troubleshoot it. This is what I've set up to try to reproduce it:
I'm probably doing something wrong in the reproduction steps. Please let me know what I should do differently to reproduce the issue so I can troubleshoot this properly. Below you can find the environment I used to run this. Node : 14.17.0
OS : linux x64
yarn : 1.22.5
nx : Not Found
@nrwl/angular : 12.3.4
@nrwl/cli : 12.3.4
@nrwl/cypress : 12.3.4
@nrwl/devkit : 12.3.4
@nrwl/eslint-plugin-nx : 12.3.4
@nrwl/express : Not Found
@nrwl/jest : 12.3.4
@nrwl/linter : 12.3.4
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 12.3.4
@nrwl/web : Not Found
@nrwl/workspace : 12.3.4
@nrwl/storybook : Not Found
@nrwl/gatsby : Not Found
typescript : 4.2.4 |
@leosvelperez thanks for trying to reproduce this :-) you can take a look at this sample projekt (just created with nx + angular + angular material): The build does not produce any output: https://gitlab.com/benjamin.boehm/angular-nx-build-test/-/jobs/1288607121 But when you remove any scss parts it suddenly does: https://gitlab.com/benjamin.boehm/angular-nx-build-test/-/jobs/1288614605 I hope this helps |
@leosvelperez I've created basic project with reproduction of this issue. When I was creating this reprodution repo I found that if I use Create with ng build (dist created):
Create with nx build (no dist created):
|
Thanks for sharing those! I was able to see the error happening using Docker, but it's a bit tricky to troubleshoot as it seems to only be happening while building the Docker image. As soon as I access the container and run the build within the container, it runs fine 🤷🏻 . I'll keep digging and I'll keep you all posted if I make any progress there. |
Same problem with mac os, regardless of using --skip-nx-cache option. |
@leosvelperez it appears to be caused by the following change in the CLI: |
For folks finding this issue, it has nothing to do with Nx caching. Nx is correctly trying to build the apps but due to a change in the Angular CLI packages, the SASS compilation is not doing anything, and somehow the build finish with no errors but no artifact is generated either. This seems to be happening only in CI environments (at least Gitlab) and when building a Docker image which makes it hard to troubleshoot. As pointed out in several comments in this thread, the issue appeared with version I'll try to spend more time on this to identify what can be done on Nx side to fix this. Unfortunately, due to the nature of the environments where this is happening, it's very time-consuming to troubleshoot it, but I'll do my best to try to find a solution for it. I renamed the issue to properly reflect what is this about and prevent confusion with Nx caching. |
FYI we're seeing this in Jenkins. So glad others have found the root cause - I wouldn't have known how to debug this! Using 12.0.0 is working for us. |
@leosvelperez I was able to reproduce this behaviour (premature exit with success code with no artifact build) on Mac as well: CI=true nx run application:build:production It was not consistent and did not reproduce on clean Angular project, but on "real" project it worked like 90% of the time. |
…en building ISSUES CLOSED: nrwl#5729
i'm able to reproduce it on win machine (success build message, no |
Hey all! I've now submitted a PR with a workaround to solve this. The issue boils down to how the Angular CLI is managing the workers that were added as part of the new SASS compilation. The workers are unref()-ed as soon as they are created and in certain environments, where nothing else is keeping the process alive, this results in the process exiting early and no compilation is done. Running with the Angular CLI works because they have an interval running for analytics while the compilation is happening and that prevents the process from exiting. I'll create an issue on the Angular CLI to try and get this sorted there, so the workaround is no longer needed, but in the meantime, this should solve the issue. We'll cut a patch release soon with the fix. |
We released version 12.3.5 with the fix. If you still have issues with that version, please let me know. |
I've moved our workspace to nx 12.3.5 and have moved forward Applications in our workspace that take 10+ minutes to compile are still bailing out as described above when using build angular 12.0.1 with nx. This fix also may have introduced a new bug: #5829 |
@jredl-va that seems to be different than the previous issue. Previously, the build was exiting with an exit status code of 0, because the process was exiting prematurely with no failures. In the screenshot you're sharing, the exit status code is 128, so it seems something else is happening. It's probably better to take a look at your CI logs to figure out the issue. I tested the 12.3.5 version with the reproduction repos that were shared in this thread and it worked correctly in them. If it's still failing in other scenarios, it might be a different issue or if it's the same I'd need a repro to be able to troubleshoot it. |
@leosvelperez I'm thinking that there has been a memory leak somehow introduced with these changes. Would you like me to open a new issue? For reference our pipeline runs on 16 core machines with 128 gigs ram. Node is given 8 gigs via node_options. The change set where we can see this error appear in our logs: Our CI runs via codefresh pipelines where the docker image is You are right that a different error is occurring here and it I missed the output earlier:
|
Yep, definitely a different issue. Currently, there are a couple of issues in the Angular CLI repo regarding performance: angular/angular-cli#20801 and angular/angular-cli#20792. I'd recommend you first to check those, as this might be an issue with the Angular CLI and not with Nx. |
@leosvelperez thank you for your time. Will redirect my comments to those issues! |
I upgraded to 12.3.5 and our CI build is no longer seeing this error. |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Description
Artifact A was built successfully and then removed from dist. If you build again, the nx cache will not do anything as it registers that there have been no changes and says "build successful" even though dist is empty.
Motivation
A CI workflow would maybe like to remove built artifacts but still keep the cache around to lower build times. If an artifact was missing but the cache registered it as built from last build, the current build will fail.
Suggested Implementation
Quick check on the existence of the artifact under dist after cache gave the artifact thumbs up. Build it again if it doesn't exist.
The text was updated successfully, but these errors were encountered: