Angular-cli: Call retries were exceeded. Allocation failed - JavaScript heap out of memory error on build

Created on 30 Dec 2019  路  17Comments  路  Source: angular/angular-cli

馃悶 Bug report

Command (mark with an x)


  • [ ] new
  • [X] 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:
@angular/cli 8.3.20
@angular-devkit/build-angular 0.803.20

Description

A clear and concise description of the problem...
After updating to 8.3.21, when I run 'ng build' or 'ng build --prod' the build reaches the 'Generating ES5 bundles for differential loading' stage. It then stops outputting information, and multiple report.xxx.json files (attached) are created, approximately 45 seconds apart.

Reverting back to 8.3.20 resolves this issue.

馃敩 Minimal Reproduction

馃敟 Exception or Error




[error] Error: Call retries were exceeded
    at ChildProcessWorker.initialize (\node_modules\@angular-devkit\build-angular\node_modules\jest-worker\build\workers\ChildProcessWorker.js:193:21)
    at ChildProcessWorker.onExit (\node_modules\@angular-devkit\build-angular\node_modules\jest-worker\build\workers\ChildProcessWorker.js:263:12)
    at ChildProcess.emit (events.js:210:5)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)

馃實 Your Environment




Angular CLI: 8.3.21
Node: 12.13.1
OS: win32 x64
Angular: 8.2.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.803.21
@angular-devkit/build-angular     0.803.21
@angular-devkit/build-optimizer   0.803.21
@angular-devkit/build-webpack     0.803.21
@angular-devkit/core              8.3.20
@angular-devkit/schematics        8.3.20
@angular/cli                      8.3.21
@ngtools/webpack                  8.3.21
@schematics/angular               8.3.21
@schematics/update                0.803.21
rxjs                              6.5.3
typescript                        3.5.3
webpack                           4.39.2

Anything else relevant?

Contents of a report file:


{
  "header": {
    "reportVersion": 1,
    "event": "Allocation failed - JavaScript heap out of memory",
    "trigger": "FatalError",
    "filename": "report.20191230.175738.18688.0.001.json",
    "dumpEventTime": "2019-12-30T17:57:38Z",
    "dumpEventTimeStamp": "1577728658928",
    "processId": 18688,
    "cwd": "C:\\Horizon_Local\\RDT_Backlog\\LandscapeWeb\\LandscapeClaim\\trunk\\src\\Rdt.Landscape.Claim.Host\\ClientApp\\LandscapeClaim",
    "commandLine": [
      "C:\\Program Files\\nodejs\\node.exe",
      "C:\\Horizon_Local\\RDT_Backlog\\LandscapeWeb\\LandscapeClaim\\trunk\\src\\Rdt.Landscape.Claim.Host\\ClientApp\\LandscapeClaim\\node_modules\\@angular-devkit\\build-angular\\node_modules\\jest-worker\\build\\workers\\processChild.js"
    ],
    "nodejsVersion": "v12.13.1",
    "wordSize": 64,
    "arch": "x64",
    "platform": "win32",
    "componentVersions": {
      "node": "12.13.1",
      "v8": "7.7.299.13-node.16",
      "uv": "1.33.1",
      "zlib": "1.2.11",
      "brotli": "1.0.7",
      "ares": "1.15.0",
      "modules": "72",
      "nghttp2": "1.39.2",
      "napi": "5",
      "llhttp": "1.1.4",
      "http_parser": "2.8.0",
      "openssl": "1.1.1d",
      "cldr": "35.1",
      "icu": "64.2",
      "tz": "2019c",
      "unicode": "12.1"
    },
    "release": {
      "name": "node",
      "lts": "Erbium",
      "headersUrl": "https://nodejs.org/download/release/v12.13.1/node-v12.13.1-headers.tar.gz",
      "sourceUrl": "https://nodejs.org/download/release/v12.13.1/node-v12.13.1.tar.gz",
      "libUrl": "https://nodejs.org/download/release/v12.13.1/win-x64/node.lib"
    },
    "osName": "Windows_NT",
    "osRelease": "10.0.17134",
    "osVersion": "Windows 10 Enterprise",
    "osMachine": "x86_64",
    "cpus": [
      {
        "model": "Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz",
        "speed": 3408,
        "user": 5664546,
        "nice": 0,
        "sys": 3876171,
        "idle": 107558468,
        "irq": 389625
      },
      {
        "model": "Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz",
        "speed": 3408,
        "user": 5153359,
        "nice": 0,
        "sys": 2473421,
        "idle": 109472218,
        "irq": 44156
      },
      {
        "model": "Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz",
        "speed": 3408,
        "user": 6340406,
        "nice": 0,
        "sys": 4032359,
        "idle": 106726234,
        "irq": 55343
      },
      {
        "model": "Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz",
        "speed": 3408,
        "user": 5864171,
        "nice": 0,
        "sys": 2212093,
        "idle": 109022734,
        "irq": 32281
      },
      {
        "model": "Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz",
        "speed": 3408,
        "user": 6080984,
        "nice": 0,
        "sys": 3754687,
        "idle": 107263328,
        "irq": 51015
      },
      {
        "model": "Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz",
        "speed": 3408,
        "user": 5027500,
        "nice": 0,
        "sys": 1923109,
        "idle": 110148390,
        "irq": 37843
      },
      {
        "model": "Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz",
        "speed": 3408,
        "user": 6650718,
        "nice": 0,
        "sys": 3162640,
        "idle": 107285640,
        "irq": 47531
      },
      {
        "model": "Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz",
        "speed": 3408,
        "user": 5141875,
        "nice": 0,
        "sys": 1924468,
        "idle": 110032656,
        "irq": 30203
      }
    ],
    "networkInterfaces": [
      {
        "name": "Ethernet",
        "internal": false,
        "mac": "3c:52:82:66:86:8a",
        "address": "fe80::e0b3:9450:6f17:1021",
        "netmask": "ffff:ffff:ffff:ffff::",
        "family": "IPv6",
        "scopeid": 10
      },
      {
        "name": "Ethernet",
        "internal": false,
        "mac": "3c:52:82:66:86:8a",
        "address": "172.16.4.117",
        "netmask": "255.255.248.0",
        "family": "IPv4"
      },
      {
        "name": "Loopback Pseudo-Interface 1",
        "internal": true,
        "mac": "00:00:00:00:00:00",
        "address": "::1",
        "netmask": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
        "family": "IPv6",
        "scopeid": 0
      },
      {
        "name": "Loopback Pseudo-Interface 1",
        "internal": true,
        "mac": "00:00:00:00:00:00",
        "address": "127.0.0.1",
        "netmask": "255.0.0.0",
        "family": "IPv4"
      }
    ],
    "host": "RDTW01284"
  },
  "javascriptStack": {
    "message": "No stack.",
    "stack": [
      "Unavailable."
    ]
  },
  "nativeStack": [
    {
      "pc": "0x00007ff788911729",
      "symbol": "std::basic_ostream >::operator<<+10873"
    },
    {
      "pc": "0x00007ff788915b4c",
      "symbol": "std::basic_ostream >::operator<<+28316"
    },
    {
      "pc": "0x00007ff788914b08",
      "symbol": "std::basic_ostream >::operator<<+24152"
    },
    {
      "pc": "0x00007ff788a0369b",
      "symbol": "v8::base::CPU::has_sse+37723"
    },
    {
      "pc": "0x00007ff7892082de",
      "symbol": "v8::Isolate::ReportExternalAllocationLimitReached+94"
    },
    {
      "pc": "0x00007ff7891f0321",
      "symbol": "v8::SharedArrayBuffer::Externalize+833"
    },
    {
      "pc": "0x00007ff7890bdbec",
      "symbol": "v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1436"
    },
    {
      "pc": "0x00007ff7890c8f90",
      "symbol": "v8::internal::Heap::ProtectUnprotectedMemoryChunks+1312"
    },
    {
      "pc": "0x00007ff7890c5ac4",
      "symbol": "v8::internal::Heap::PageFlagsAreConsistent+3204"
    },
    {
      "pc": "0x00007ff7890bb353",
      "symbol": "v8::internal::Heap::CollectGarbage+1283"
    },
    {
      "pc": "0x00007ff7890b9b24",
      "symbol": "v8::internal::Heap::AddRetainedMap+2356"
    },
    {
      "pc": "0x00007ff7890dadf5",
      "symbol": "v8::internal::Factory::NewFillerObject+53"
    },
    {
      "pc": "0x00007ff788e46e19",
      "symbol": "v8::internal::interpreter::JumpTableTargetOffsets::iterator::operator=+4057"
    },
    {
      "pc": "0x00007ff78963404d",
      "symbol": "v8::internal::SetupIsolateDelegate::SetupHeap+567949"
    },
    {
      "pc": "0x000001246cf93443",
      "symbol": ""
    }
  ],
  "javascriptHeap": {
    "totalMemory": 2150961152,
    "totalCommittedMemory": 2150961152,
    "usedMemory": 2129135824,
    "availableMemory": 52074808,
    "memoryLimit": 2197815296,
    "heapSpaces": {
      "read_only_space": {
        "memorySize": 262144,
        "committedMemory": 262144,
        "capacity": 261872,
        "used": 32296,
        "available": 229576
      },
      "new_space": {
        "memorySize": 2097152,
        "committedMemory": 2097152,
        "capacity": 1047488,
        "used": 212944,
        "available": 834544
      },
      "old_space": {
        "memorySize": 2031726592,
        "committedMemory": 2031726592,
        "capacity": 2016133088,
        "used": 2013024032,
        "available": 3109056
      },
      "code_space": {
        "memorySize": 1736704,
        "committedMemory": 1736704,
        "capacity": 1449632,
        "used": 1449632,
        "available": 0
      },
      "map_space": {
        "memorySize": 1576960,
        "committedMemory": 1576960,
        "capacity": 1048640,
        "used": 1048640,
        "available": 0
      },
      "large_object_space": {
        "memorySize": 113512448,
        "committedMemory": 113512448,
        "capacity": 113364728,
        "used": 113364728,
        "available": 0
      },
      "code_large_object_space": {
        "memorySize": 49152,
        "committedMemory": 49152,
        "capacity": 3552,
        "used": 3552,
        "available": 0
      },
      "new_large_object_space": {
        "memorySize": 0,
        "committedMemory": 0,
        "capacity": 1047488,
        "used": 0,
        "available": 1047488
      }
    }
  },
  "resourceUsage": {
    "userCpuSeconds": 126.578,
    "kernelCpuSeconds": 3.328,
    "cpuConsumptionPercent": 216.51,
    "maxRss": 2282307584,
    "pageFaults": {
      "IORequired": 1079275,
      "IONotRequired": 0
    },
    "fsActivity": {
      "reads": 2654,
      "writes": 109
    }
  },
  "libuv": [
  ],
  "environmentVariables": {
    REMOVED
  },
  "sharedObjects": [
    "C:\\Program Files\\nodejs\\node.exe",
    "C:\\WINDOWS\\SYSTEM32\\ntdll.dll",
    "C:\\WINDOWS\\System32\\KERNEL32.DLL",
    "C:\\WINDOWS\\System32\\KERNELBASE.dll",
    "C:\\WINDOWS\\System32\\WS2_32.dll",
    "C:\\WINDOWS\\System32\\RPCRT4.dll",
    "C:\\WINDOWS\\SYSTEM32\\dbghelp.dll",
    "C:\\WINDOWS\\System32\\ucrtbase.dll",
    "C:\\WINDOWS\\System32\\ADVAPI32.dll",
    "C:\\WINDOWS\\System32\\msvcrt.dll",
    "C:\\WINDOWS\\System32\\sechost.dll",
    "C:\\WINDOWS\\System32\\USER32.dll",
    "C:\\WINDOWS\\System32\\win32u.dll",
    "C:\\WINDOWS\\System32\\GDI32.dll",
    "C:\\WINDOWS\\System32\\gdi32full.dll",
    "C:\\WINDOWS\\System32\\msvcp_win.dll",
    "C:\\WINDOWS\\System32\\PSAPI.DLL",
    "C:\\WINDOWS\\System32\\CRYPT32.dll",
    "C:\\WINDOWS\\System32\\MSASN1.dll",
    "C:\\WINDOWS\\SYSTEM32\\IPHLPAPI.DLL",
    "C:\\WINDOWS\\SYSTEM32\\USERENV.dll",
    "C:\\WINDOWS\\SYSTEM32\\bcrypt.dll",
    "C:\\WINDOWS\\System32\\profapi.dll",
    "C:\\WINDOWS\\SYSTEM32\\WINMM.dll",
    "C:\\WINDOWS\\SYSTEM32\\WINMMBASE.dll",
    "C:\\WINDOWS\\System32\\cfgmgr32.dll",
    "C:\\WINDOWS\\System32\\IMM32.DLL",
    "C:\\WINDOWS\\System32\\powrprof.dll",
    "C:\\WINDOWS\\SYSTEM32\\CRYPTBASE.DLL",
    "C:\\WINDOWS\\System32\\bcryptPrimitives.dll",
    "C:\\WINDOWS\\system32\\uxtheme.dll",
    "C:\\WINDOWS\\System32\\combase.dll",
    "C:\\WINDOWS\\system32\\mswsock.dll",
    "C:\\WINDOWS\\System32\\kernel.appcore.dll",
    "C:\\WINDOWS\\System32\\NSI.dll",
    "C:\\WINDOWS\\SYSTEM32\\dhcpcsvc6.DLL",
    "C:\\WINDOWS\\SYSTEM32\\dhcpcsvc.DLL",
    "C:\\WINDOWS\\system32\\napinsp.dll",
    "C:\\WINDOWS\\system32\\pnrpnsp.dll",
    "C:\\WINDOWS\\system32\\NLAapi.dll",
    "C:\\WINDOWS\\SYSTEM32\\DNSAPI.dll",
    "C:\\WINDOWS\\System32\\winrnr.dll",
    "C:\\WINDOWS\\System32\\wshbth.dll"
  ]
}
devkibuild-angular high regression bufix

Most helpful comment

The recently released version of the CLI (8.3.22) has several improvements to prevent excessive memory usage when processing source maps. Based on the provided reproductions, the memory usage issues were no longer present when using the new version.
For anyone experiencing memory issues, please update to the latest CLI version (currently 8.3.22). Also ensure that the @angular-devkit/build-angular version is at least 0.803.22. This package contains a majority of the build processing logic. It is also recommended to use the latest version of Node.js 12 as well (currently 12.14.1).

If anyone is still encountering issues after ensuring these changes, please open a new issue describing the problem and if possible provide a minimal reproduction.
In addition, please be aware that Node.js has a default memory limit of ~2GB and that for very large projects this may need to be increased. This can be accomplished via the following:
node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng build
The 4096 value essentially represents a maximum memory usage value for the node process in megabytes. For this example, that would be 4GB of memory but can be adjusted as needed. Ensure that the system has enough physical memory to support the value chosen.

All 17 comments

Can you provide the console output of the successful build? The amount and sizes of the output files are of particular interest.
Please also provide the options used within the angular.json file that would be used for a production build of the project. This would include the options object and the production configuration object for thebuild` target.
Do you happen to know what the total system memory as well as the available system memory was prior to executing the build?

Also of concern is that the following are not at .21 as the other dependencies are:

@angular-devkit/core              8.3.20
@angular-devkit/schematics        8.3.20

Are these manually specified in the workspace's package.json?

Thanks for the response.

Sorry to repeat, but this is failing on both debug and production environments.

However, on a successful build:

ng build --prod


chunk {2} polyfills-es2015.2987770fde9daa1d8a2e.js (polyfills) 36.4 kB [initial] [rendered]
chunk {3} polyfills-es5.f4117c6b6f3a962d44da.js (polyfills-es5) 123 kB [initial] [rendered]
chunk {0} runtime-es2015.edb2fcf2778e7bf1d426.js (runtime) 1.45 kB [entry] [rendered]
chunk {0} runtime-es5.edb2fcf2778e7bf1d426.js (runtime) 1.45 kB [entry] [rendered]
chunk {1} main-es2015.2fa44e8f7be6fc617896.js (main) 1.61 MB [initial] [rendered]
chunk {1} main-es5.2fa44e8f7be6fc617896.js (main) 1.74 MB [initial] [rendered]
chunk {4} styles.31f048d8483ad21f5528.css (styles) 138 kB [initial] [rendered]
Date: 2019-12-30T20:28:49.623Z - Hash: fe75005aa7bb7be37287 - Time: 52164ms

ng build


chunk {polyfills-es5} polyfills-es5.js, polyfills-es5.js.map (polyfills-es5) 896 kB [initial] [rendered]
chunk {main} main-es2015.js, main-es2015.js.map (main) 2.61 MB [initial] [rendered]
chunk {main} main-es5.js, main-es5.js.map (main) 3.07 MB [initial] [rendered]
chunk {styles} styles-es2015.js, styles-es2015.js.map (styles) 832 kB [initial] [rendered]
chunk {styles} styles-es5.js, styles-es5.js.map (styles) 837 kB [initial] [rendered]
chunk {runtime} runtime-es2015.js, runtime-es2015.js.map (runtime) 6.16 kB [entry] [rendered]
chunk {runtime} runtime-es5.js, runtime-es5.js.map (runtime) 6.2 kB [entry] [rendered]
chunk {vendor} vendor-es2015.js, vendor-es2015.js.map (vendor) 6.73 MB [initial] [rendered]
chunk {vendor} vendor-es5.js, vendor-es5.js.map (vendor) 9.45 MB [initial] [rendered]
chunk {polyfills} polyfills-es2015.js, polyfills-es2015.js.map (polyfills) 290 kB [initial] [rendered]
Date: 2019-12-30T20:30:16.209Z - Hash: 67b19bd1e1af07261fb8 - Time: 27477ms

angular.json


        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/LandscapeClaim",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": ["src/favicon.ico", "src/assets"],
            "styles": ["src/styles.scss"],
            "stylePreprocessorOptions": {
              "includePaths": ["src/scss"]
            },
            "scripts": []
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "5mb"
                }
              ]
            }
          }
        },

Memory
System memory = 16GB
In use = 9.3GB
Versions
The only reference to @angular-devkit is within the devDependencies


  "devDependencies": {
    "@angular-devkit/build-angular": "~0.803.21",
    "@angular/cli": "^8.3.21",
    "@angular/compiler-cli": "~8.2.14",
    "@angular/language-service": "~8.2.14",

Hope this helps

I have exact same issue, need help

From #16520

ES5 bundles fail to be generated with the error "Maximum call stack size exceeded". In my case, I am building an application with Ionic, which leverages ES5. This appears to have been introduced with this commit.

I have created a repository that demonstrates this bug.

Checkout https://github.com/devinshoemaker/repro-max-call-stack
npm install
ng build
If you downgrade @angular-devkit/build-angular then build will complete successfully.

npm install @angular-devkit/[email protected]
ng build
Issues that don't have enough info and can't be reproduced will be closed.

From #16520

ES5 bundles fail to be generated with the error "Maximum call stack size exceeded". In my case, I am building an application with Ionic, which leverages ES5. This appears to have been introduced with this commit.

I have created a repository that demonstrates this bug.

Checkout https://github.com/devinshoemaker/repro-max-call-stack
npm install
ng build
If you downgrade @angular-devkit/build-angular then build will complete successfully.

npm install @angular-devkit/[email protected]
ng build
Issues that don't have enough info and can't be reproduced will be closed.

An update to this; changing the target property in tsconfig.json from es2015 to es5 results in a successful build.

FYI, changing to ES5 allowed my build to go through too

@devinshoemaker same here! changing to ES5 allowed my build to go through too.

Changing the target to es5 disables differential loading, which may not be desired in all cases.
https://angular.io/guide/deployment#differential-loading

Facing this on a CI pipeline as well. And have no desire to turn off differential builds.
Or, only disabling for a particular configuration in angular.json might be a feasible solution for me.

@AhsanAyaz you might try this workaround that was posted in a different issue: https://github.com/angular/angular-cli/issues/16520#issuecomment-569970189

Facing this on a CI pipeline as well. And have no desire to turn off differential builds.
Or, only disabling for a particular configuration in angular.json might be a feasible solution for me.

The above was my use-case. If you also want to disable the differential loading only for a certain configuration, you can create a new tsconfig.something.json inside the src folder, similar to tsconfig.app.json.

For my case, I created a tsconfig.devserver.json with the following content:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "types": [],
    "target": "ES5",
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}

And then I'm just running the below script to not ruin my other builds which use optimizations and are successful at the moment:

ng build --configuration=devserver --ts-config ./src/tsconfig.devserver.json 
  • Fixed the problem for me 馃帀
  • Didn't have to modify tsconfig.app.json 馃挜

It is working again for me with the latest versions (released a few hours ago):

"@angular-devkit/build-angular": "~0.803.22",
"@angular/cli": "~8.3.22",

The recently released version of the CLI (8.3.22) has several improvements to prevent excessive memory usage when processing source maps. Based on the provided reproductions, the memory usage issues were no longer present when using the new version.
For anyone experiencing memory issues, please update to the latest CLI version (currently 8.3.22). Also ensure that the @angular-devkit/build-angular version is at least 0.803.22. This package contains a majority of the build processing logic. It is also recommended to use the latest version of Node.js 12 as well (currently 12.14.1).

If anyone is still encountering issues after ensuring these changes, please open a new issue describing the problem and if possible provide a minimal reproduction.
In addition, please be aware that Node.js has a default memory limit of ~2GB and that for very large projects this may need to be increased. This can be accomplished via the following:
node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng build
The 4096 value essentially represents a maximum memory usage value for the node process in megabytes. For this example, that would be 4GB of memory but can be adjusted as needed. Ensure that the system has enough physical memory to support the value chosen.

FYI, changing to ES5 allowed my build to go through too

run for me too

@devinshoemaker same here! changing to ES5 allowed my build to go through too.

changing to ES5 not working here

I have encountered the same issue now when trying to build for test env using anuglar 9 with ivy disabled

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._

Was this page helpful?
0 / 5 - 0 ratings