Closed robertIsaac closed 1 month ago
I've been experiencing this issue for a while now. Recently with the Angular 18 update it seems to be occurring more often.
Here's some info about my project:
browser-esbuild
build systemI tried the following without success:
@import
into @use
stylePreprocessorOptions
Reading this thread and trying your suggestions, I added the following env into my flaky build:
CI: true
NG_BUILD_MAX_WORKERS: 1
nx --parallel=false
This seems to have improved the reliability (no failure since I added that). I have to keep monitoring this over a longer period, but this looks like it's having a positive effect.
We're using Azure and have an NX Angular 17 monorepo with 11 apps, but we are building only one single app at a time. We also have around 25 libs built together with that app. We used to have intermittent failures like this, but using NG_BUILD_MAX_WORKERS: 1
seems to solve it.
@alan-agius4 thanks for your investigation and solutions! 🤗
Also, there's something unclear to me: setting NG_BUILD_MAX_WORKERS
is just a workaround, but your fix here is the correct fix, right? In the latest Angular is the NG_BUILD_MAX_WORKERS
taken into consideration?
Also, there's something unclear to me: setting NG_BUILD_MAX_WORKERS is just a workaround, but your fix https://github.com/angular/angular-cli/pull/27969 is the correct fix, right? In the latest Angular is the NG_BUILD_MAX_WORKERS taken into consideration?
yes
Great that the issue seems to be fixed in the latest build. However, it's unclear to me which Angular versions got this fix.
Here it says that "the changes were merged into the following branches: main, 18.0.x, 18.1.x".
What about Angular 17? Is the fix included right there or not? Do I have to update to Angular 18 in order to get the fix?
@MelanieW97, no version 17 is in LTS as such it only receives security fixes. See https://angular.dev/reference/releases#lts-fixes for more information.
In earlier versions setting the above mentioned environment variable is required.
Is https://github.com/angular/angular-cli/pull/27969 really a fix for the root cause? It sounds more like a way to decrease the likelihood of the problem without special configuration. This is still good, but what do we know about the root cause so far?
Is #27969 really a fix for the root cause? It sounds more like a way to decrease the likelihood of the problem without special configuration. This is still good, but what do we know about the root cause so far?
That's exactly what I thought before @alan-agius4 clarified it's a fix. Thanks for asking. :)
It is an improvement to detect the maximum number of workers that can be used within containers instead of using NG_BUILD_MAX_WORKERS
. For more details, see this issue comment.
This failure commonly occurred when the container lacked sufficient resources to manage the builds, particularly when using parallel builds.
This failure commonly occurred when the container lacked sufficient resources to manage the builds, particularly when using parallel builds.
If the root cause is insufficient resources, is there a way to detect this and improve the error message? :thinking:
This failure commonly occurred when the container lacked sufficient resources to manage the builds, particularly when using parallel builds.
If the root cause is insufficient resources, is there a way to detect this and improve the error message? 🤔
I guess because nobody reported that they managed to reproduce it on a local computer (usually with decent resources) it's good enough to consider it a lack of resources issue. Everybody reported that it only happens on CIs.
[...] I guess because nobody reported that they managed to reproduce it on a local computer (usually with decent resources) it's good enough to consider it a lack of resources issue. Everybody reported that it only happens on CIs.
Still does not answer @ptandler`s point if it is possible to detect if there is insufficient resources and give a proper warning/error.
Everybody reported that it only happens on CIs.
@sergiubologa no idea if it's the same issue, but I can reproduce such problem on local:
pnpm install --no-frozen-lockfile
pnpm run lib:test:build
@alan-agius4
I confirm that after setting NG_BUILD_MAX_WORKERS
to 1, it stopped failing now in both ng build
and ng serve
I have one question, when we upgrade to Angular 18 (we will go directly to 18.1), do we still need this?
@robertIsaac, glad to hear that. No, there shouldn’t be need.
I upgraded an application to 18.1 because of this, and it's happening much less frequently, but I've just encountered a failed pipeline.
package.json:
"dependencies": {
"@angular/animations": "18.1.1",
"@angular/cdk": "18.1.1",
"@angular/common": "18.1.1",
"@angular/compiler": "18.1.1",
"@angular/core": "18.1.1",
"@angular/forms": "18.1.1",
"@angular/material": "18.1.1",
"@angular/material-luxon-adapter": "18.1.1",
"@angular/platform-browser": "18.1.1",
"@angular/platform-browser-dynamic": "18.1.1",
"@angular/router": "18.1.1",
"@azure/msal-angular": "3.0.22",
"@azure/msal-browser": "3.19.1",
"@ngx-translate/core": "15.0.0",
"rxjs": "7.8.1",
"tslib": "2.6.3",
"zone.js": "0.14.8"
<... REMOVED A FEW THAT IS NOT RELEVANT TO THIS...>
},
"devDependencies": {
"@angular-eslint/builder": "18.1.0",
"@angular-eslint/eslint-plugin": "18.1.0",
"@angular-eslint/eslint-plugin-template": "18.1.0",
"@angular-eslint/schematics": "18.1.0",
"@angular-eslint/template-parser": "18.1.0",
"@angular/build": "18.1.1",
"@angular/cli": "18.1.1",
"@angular/compiler-cli": "18.1.1",
"@typescript-eslint/parser": "7.16.1",
"eslint": "9.7.0",
"typescript": "5.5.3"
<... REMOVED A FEW THAT IS NOT RELEVANT TO THIS...>
}
I'm buliding it in a docker container after restoring with pnpm:
FROM node:20-alpine AS web-app-restore
COPY ./[REDACTED] ./app
WORKDIR /app
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN node node_modules/@angular/cli/bin/ng build
2024-07-24T09:36:42.3518508Z ##[section]Starting: [REDACTED]
2024-07-24T09:36:42.3524793Z ==============================================================================
2024-07-24T09:36:42.3524949Z Task : Command line
2024-07-24T09:36:42.3525020Z Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
2024-07-24T09:36:42.3525126Z Version : 2.237.1
2024-07-24T09:36:42.3525195Z Author : Microsoft Corporation
2024-07-24T09:36:42.3525292Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
2024-07-24T09:36:42.3525397Z ==============================================================================
2024-07-24T09:36:42.5268490Z Generating script.
2024-07-24T09:36:42.5279476Z Script contents:
2024-07-24T09:36:42.5280481Z docker build -t [REDACTED] --target [REDACTED] .
2024-07-24T09:36:42.5281092Z ========================== Starting Command Output ===========================
2024-07-24T09:36:42.5308327Z [command]/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/a6853ee0-b08d-4bba-a8cf-54399c02a4bf.sh
2024-07-24T09:36:42.9391432Z #0 building with "default" instance using docker driver
2024-07-24T09:36:42.9391982Z
2024-07-24T09:36:42.9392255Z #1 [internal] load build definition from Dockerfile
2024-07-24T09:36:42.9392546Z #1 transferring dockerfile: 4.11kB done
2024-07-24T09:36:42.9392789Z #1 DONE 0.0s
2024-07-24T09:36:42.9392960Z
2024-07-24T09:36:42.9393579Z #2 [internal] load metadata for docker.io/library/node:20-alpine
2024-07-24T09:36:42.9393962Z #2 DONE 0.0s
2024-07-24T09:36:42.9394111Z
2024-07-24T09:36:42.9394478Z #3 [internal] load metadata for mcr.microsoft.com/dotnet/sdk:8.0-alpine
2024-07-24T09:36:42.9394765Z #3 DONE 0.1s
2024-07-24T09:36:42.9395361Z
2024-07-24T09:36:42.9395640Z #4 [internal] load metadata for docker.io/joshkeegan/zip:latest
2024-07-24T09:36:42.9871867Z #4 DONE 0.3s
2024-07-24T09:36:43.2086263Z
2024-07-24T09:36:43.2087142Z #5 [internal] load .dockerignore
2024-07-24T09:36:43.2089719Z #5 transferring context: 388B done
2024-07-24T09:36:43.2089902Z #5 DONE 0.0s
2024-07-24T09:36:43.2089969Z
2024-07-24T09:36:43.2091006Z #6 [[REDACTED] 1/5] FROM docker.io/joshkeegan/zip:latest@sha256:0bd6fa12624ffca089d0746a387dacf8c72018db9b9c1f21e9ac72d86c045447
2024-07-24T09:36:43.2091228Z #6 DONE 0.0s
2024-07-24T09:36:43.2091277Z
2024-07-24T09:36:43.2091816Z #7 [dotnet-restore 1/7] FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine@sha256:6e8997576d16a6d7b4e6ba7ac0956d3ae46cb7a376581c40eabd20fbc5c28b8d
2024-07-24T09:36:43.2092137Z #7 DONE 0.0s
2024-07-24T09:36:43.2092204Z
2024-07-24T09:36:43.2092440Z #8 [web-app-restore 1/6] FROM docker.io/library/node:20-alpine
2024-07-24T09:36:43.2092691Z #8 DONE 0.0s
2024-07-24T09:36:43.2092757Z
2024-07-24T09:36:43.2092915Z #9 [internal] load build context
2024-07-24T09:36:43.2093145Z #9 transferring context: 82.71kB 0.0s done
2024-07-24T09:36:43.2093314Z #9 DONE 0.1s
2024-07-24T09:36:43.2093362Z
2024-07-24T09:36:43.2093659Z #10 [web-app-restore 5/6] RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
2024-07-24T09:36:43.2093958Z #10 CACHED
2024-07-24T09:36:43.2094023Z
2024-07-24T09:36:43.2094242Z #11 [web-app-restore 4/6] RUN corepack enable
2024-07-24T09:36:43.2094456Z #11 CACHED
2024-07-24T09:36:43.2094537Z
2024-07-24T09:36:43.2094762Z #12 [web-app-restore 2/6] COPY ./[REDACTED] ./app
2024-07-24T09:36:43.2095001Z #12 CACHED
2024-07-24T09:36:43.2095064Z
2024-07-24T09:36:43.2095268Z #13 [web-app-restore 3/6] WORKDIR /app
2024-07-24T09:36:43.2095478Z #13 CACHED
2024-07-24T09:36:43.2095542Z
2024-07-24T09:36:43.2095857Z #14 [web-app-restore 6/6] RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
2024-07-24T09:36:43.2096119Z #14 CACHED
2024-07-24T09:36:43.2096202Z
2024-07-24T09:36:43.2096484Z #15 [[REDACTED] 1/1] RUN node node_modules/@angular/cli/bin/ng build [REDACTED]
2024-07-24T09:36:44.4280152Z #15 1.372 - Building...
2024-07-24T09:36:44.4281369Z #15 1.372
2024-07-24T09:37:19.5318723Z #15 36.48 Application bundle generation failed. [35.098 seconds]
2024-07-24T09:37:19.5319273Z #15 36.48
2024-07-24T09:37:19.6897105Z #15 36.48 ✘ [ERROR] Can't find stylesheet to import.
2024-07-24T09:37:19.6897610Z #15 36.48 ╷
2024-07-24T09:37:19.6897933Z #15 36.48 27 │ @use '@material/theme/selector-ext';
2024-07-24T09:37:19.6898242Z #15 36.48 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-07-24T09:37:19.6898456Z #15 36.48 ╵
2024-07-24T09:37:19.6898992Z #15 36.48 node_modules/.pnpm/@material+rtl@15.0.0-canary.7f224ddd4.0/node_modules/@material/rtl/_rtl.scss 27:1 @use
2024-07-24T09:37:19.6899636Z #15 36.48 node_modules/.pnpm/@material+elevation@15.0.0-canary.7f224ddd4.0/node_modules/@material/elevation/_elevation-theme.scss 33:1 @use
2024-07-24T09:37:19.6900159Z #15 36.48 node_modules/.pnpm/@angular+material@18.1.1_@angular+animations@18.1.1_@angular+core@18.1.1_rxjs@7.8.1_zone.js@0_524xgukklzklncwxtrn3vxgbcm/node_modules/@angular/material/core/style/_elevation.scss 4:1 @use
2024-07-24T09:37:19.6900697Z #15 36.48 node_modules/.pnpm/@angular+material@18.1.1_@angular+animations@18.1.1_@angular+core@18.1.1_rxjs@7.8.1_zone.js@0_524xgukklzklncwxtrn3vxgbcm/node_modules/@angular/material/core/tokens/m3/mat/_app.scss 2:1 @use
2024-07-24T09:37:19.6901234Z #15 36.48 node_modules/.pnpm/@angular+material@18.1.1_@angular+animations@18.1.1_@angular+core@18.1.1_rxjs@7.8.1_zone.js@0_524xgukklzklncwxtrn3vxgbcm/node_modules/@angular/material/core/tokens/m3/_index.scss 3:1 @use
2024-07-24T09:37:19.6901997Z #15 36.48 node_modules/.pnpm/@angular+material@18.1.1_@angular+animations@18.1.1_@angular+core@18.1.1_rxjs@7.8.1_zone.js@0_524xgukklzklncwxtrn3vxgbcm/node_modules/@angular/material/core/tokens/_m3-tokens.scss 5:1 @use
2024-07-24T09:37:19.6903014Z #15 36.48 node_modules/.pnpm/@angular+material@18.1.1_@angular+animations@18.1.1_@angular+core@18.1.1_rxjs@7.8.1_zone.js@0_524xgukklzklncwxtrn3vxgbcm/node_modules/@angular/material/core/theming/_definition.scss 6:1 @forward
2024-07-24T09:37:19.6904272Z #15 36.48 node_modules/.pnpm/@angular+material@18.1.1_@angular+animations@18.1.1_@angular+core@18.1.1_rxjs@7.8.1_zone.js@0_524xgukklzklncwxtrn3vxgbcm/node_modules/@angular/material/_index.scss 7:1 @use
2024-07-24T09:37:19.6904901Z #15 36.48 src/styles/styles.scss 1:1 root stylesheet [plugin angular-sass]
2024-07-24T09:37:19.6905078Z #15 36.48
2024-07-24T09:37:19.6905246Z #15 36.48 angular:styles/global:styles:1:8:
2024-07-24T09:37:19.6905488Z #15 36.48 1 │ @import 'src/styles/styles.scss';
2024-07-24T09:37:19.6905744Z #15 36.48 ╵ ~~~~~~~~~~~~~~~~~~~~~~~~
2024-07-24T09:37:19.6905883Z #15 36.48
2024-07-24T09:37:19.6906001Z #15 36.48
2024-07-24T09:37:19.7292118Z #15 ERROR: process "/bin/sh -c node node_modules/@angular/cli/bin/ng build [REDACTED]" did not complete successfully: exit code: 1
2024-07-24T09:37:19.7712705Z ------
2024-07-24T09:37:19.7713163Z > [[REDACTED] 1/1] RUN node node_modules/@angular/cli/bin/ng build [REDACTED]:
2024-07-24T09:37:19.7773221Z 36.48 node_modules/.pnpm/@angular+material@18.1.1_@angular+animations@18.1.1_@angular+core@18.1.1_rxjs@7.8.1_zone.js@0_524xgukklzklncwxtrn3vxgbcm/node_modules/@angular/material/core/tokens/_m3-tokens.scss 5:1 @use
2024-07-24T09:37:19.7776688Z 36.48 node_modules/.pnpm/@angular+material@18.1.1_@angular+animations@18.1.1_@angular+core@18.1.1_rxjs@7.8.1_zone.js@0_524xgukklzklncwxtrn3vxgbcm/node_modules/@angular/material/core/theming/_definition.scss 6:1 @forward
2024-07-24T09:37:19.7777210Z 36.48 node_modules/.pnpm/@angular+material@18.1.1_@angular+animations@18.1.1_@angular+core@18.1.1_rxjs@7.8.1_zone.js@0_524xgukklzklncwxtrn3vxgbcm/node_modules/@angular/material/_index.scss 7:1 @use
2024-07-24T09:37:19.7778157Z 36.48 src/styles/styles.scss 1:1 root stylesheet [plugin angular-sass]
2024-07-24T09:37:19.7778443Z 36.48
2024-07-24T09:37:19.7778851Z 36.48 angular:styles/global:styles:1:8:
2024-07-24T09:37:19.7779158Z 36.48 1 │ @import 'src/styles/styles.scss';
2024-07-24T09:37:19.7779400Z 36.48 ╵ ~~~~~~~~~~~~~~~~~~~~~~~~
2024-07-24T09:37:19.7779522Z 36.48
2024-07-24T09:37:19.7779635Z 36.48
2024-07-24T09:37:19.7779771Z ------
2024-07-24T09:37:19.7779885Z Dockerfile:108
2024-07-24T09:37:19.7780061Z --------------------
2024-07-24T09:37:19.7780175Z 106 |
2024-07-24T09:37:19.7780389Z 107 | FROM [REDACTED] // I have a multistage dockerfile, but should not be relevant
2024-07-24T09:37:19.7780680Z 108 | >>> RUN node node_modules/@angular/cli/bin/ng build [REDACTED]
2024-07-24T09:37:19.7780848Z 109 |
2024-07-24T09:37:19.7780963Z 110 | FROM scratch AS web-app
2024-07-24T09:37:19.7781144Z --------------------
2024-07-24T09:37:19.7781519Z ERROR: failed to solve: process "/bin/sh -c node node_modules/@angular/cli/bin/ng build [REDACTED]" did not complete successfully: exit code: 1
2024-07-24T09:37:19.7867764Z
2024-07-24T09:37:19.7966976Z ##[error]Bash exited with code '1'.
2024-07-24T09:37:19.7982231Z ##[section]Finishing: [REDACTED]
Starting with version 18.1.2, @angular/material
no longer depends on @material
packages. This change should help decrease file resolution issues and minimize build failures related to resource constraints.
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.
Command
build
Is this a regression?
The previous version in which this bug was not present was
No response
Description
about 5% of our pipeline fail with this error
it happened only one with
ng serve
and it was very difficult to resolve, my colleague had to uninstall node and install it again previously he tried to delete the project and clone it again, remove yarn cache but neither workMinimal Reproduction
it's impossible to reproduce, since even rerunning the same one succeed it's not code error
this happens even when we were using webpack (we are using the application builder which uses esbuild), I noticed it in versions 15 and 17 of Angular
Exception or Error
Your Environment
Anything else relevant?
No response