Skip to content

Ng build fails always using aws codebuild  #18080

@ramimohammad

Description

@ramimohammad

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, the previous version in which this bug was not present was: ....
No

Description

We're using aws codebuild for building and the build process always fails and exits without providing any info , it says : Command did not exit successfully , the full message is : "Command did not exit successfully node --max-old-space-size=4096 node_modules/@angular/cli/bin/ng build --prod exit status 1".

🔬 Minimal Reproduction

I'm going to mention aws codebuild support team response as following :
"""
Hi Rami,

I hope you are doing well and taking good care of your health during this pandemic. Thank you for getting back to us with the requested information. I am glad to assist you further.

Before I commence, I would like to apologise for the delayed response. As I was replicating the issue in my environment, it took me a while to get back to you. I hope that you understand it and co-operate with me.

Investigation made -

Initially I have thoroughly gone through the "verbose" log you have sent me on the case. However, even in the verbose logs, I was unable to observe any particular error messages. Later, I have made use of the "package.json" file to install the same dependencies which you are using to test the build.

I installed the dependencies and used them in the CodeBuild environment to build a sample application. To replicate the issue exactly, I have made use of the same compute type and compute environment in the codebuild project that you are making use of. The environment information where I have tested the sample application is given below. However, the issue was not reproduce-able in my environment.


type LINUX_CONTAINER
image aws/codebuild/standard:3.0
computeType BUILD_GENERAL1_MEDIUM
privilegedMode false
certificate blank
registryCredential blank
imagePullCredentialsType CODEBUILD

Later, As my area of expertise is AWS CodeBuild, to gain more understanding about the Angular CLI and "ng build" I have gone through the Angular documentations. After that, to check if there are any existing issues in the angular CLI, I checked all the existing Git issues of the Angular CLI. I found the actual issue on git where, the "ng build" just fails without any particular reason. Below is the link to the issue description.

Errors in child compilers not reported, process exits without info #17565 - #17565

The issue affects "ng build" and "ng serve" commands. Accordingly, If a compilation includes child compilations as is the case when using worker-loader for example (or many other webpack loaders/plugins) the build process can fail and exit without providing any info but the exit code being 1.

The replication steps for this error with the replication repository is given in the issue description itself. I have tried this both in my local environment and in CodeBuild as well.

When I tried in the Local machine the build looks like completed as the error is not visible in the console. The local build output which I ran is given below:


8c859032105a:angular-child-compiler-error user$ node --max-old-space-size=4096 node_modules/@angular/cli/bin/ng build --prod
Browserslist: caniuse-lite is outdated. Please run next command npm update

Date: 2020-06-27T07:11:23.605Z
Hash: c773dc7753f32d162a5b
Time: 13047ms
chunk {0} runtime-es5.967b40d860653894bbb2.js (runtime) 1.45 kB [entry] [rendered]
chunk {1} main-es5.6a83abc16d1e39382351.js (main) 188 kB [initial] [rendered]
chunk {2} polyfills-es5.4e06eb653a3c8a2d581f.js (polyfills) 111 kB [initial] [rendered]

8c859032105a:angular-child-compiler-error user$ echo $?
1
8c859032105a:angular-child-compiler-error user$


You can see that the build looks completed in the local machine. However, the exit code of the command is 1. This can be the reason that the Build looks like working fine when it ran Locally in your case as well.

To replicate the issue in CodeBuild environment, I have made use of the below buildspec file and the replication was successful. You can use this buildspec for the further replication on you end.


version: 0.2

phases:
build:
commands:
- git init
- git clone https://github.com/nadavsinai/angular-child-compiler-error.git
- cd angular-child-compiler-error
- npm install
- node --max-old-space-size=4096 node_modules/@angular/cli/bin/ng build --prod --verbose

I have also tried with the angularcli vesrion 8.0.6 and 8.0.3 which is running in your environment. This version also has the same issue and the error is reproduce-able.

========================================================================================

Having said that, the issue seems more specific to the anularcli and application you are building rather than the CodeBuild environment. As I have just started with the Angular and My area of expertise is AWS CodeBuild, I may not able to debug the reason for the error. However, we can be sure that AWS CodeBuild is not having any direct relation with the issue we are observing. Rather, the issue is specific to angular and how it handles the compilation which includes child compilations. I hope that you understand this.
""""

🔥 Exception or Error


Command did not exit successfully node --max-old-space-size=4096 node_modules/@angular/cli/bin/ng build --prod exit status 1

🌍 Your Environment



Angular CLI: 8.0.3
Node: 12.16.1
OS: linux x64
Angular: 8.0.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.3
@angular-devkit/build-angular     0.800.3
@angular-devkit/build-optimizer   0.800.3
@angular-devkit/build-webpack     0.800.3
@angular-devkit/core              8.0.3
@angular-devkit/schematics        8.0.3
@angular/cdk                      8.0.1
@angular/cli                      8.0.3
@angular/material                 8.0.1
@angular/pwa                      0.901.6
@angular/service-worker           8.0.3
@ngtools/webpack                  8.0.3
@schematics/angular               8.0.3
@schematics/update                0.800.3
rxjs                              6.4.0
typescript                        3.4.5
webpack                           4.30.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions