nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
22.64k stars 2.26k forks source link

--max_old_space_size=8192 is not cascaded to ng commands in v9.2.3 #3004

Closed manandkumaar closed 4 years ago

manandkumaar commented 4 years ago

Please make sure you have read the submission guidelines before posting an issue

Prerequisites

Please answer the following questions for yourself before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

Expected Behavior

Building the app is not running into: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Current Behavior

After update to "@nrwl/workspace": "9.2.3" build is failing

Failure Information (for bugs)

Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Create empty nx angular workspace (ie. npx create-nx-workspace@latest nx9-sample`)
  2. update title in app.component.ts
  3. Update scripts as below "ng": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng.js", "nx": "node --max_old_space_size=8192 node_modules/@nrwl/cli/bin/nx.js", "affected:build": "node --max_old_space_size=8192 node_modules/@nrwl/cli/bin/nx.js affected:build",
  4. npm run affected:build

Current behavior:-

> node --max_old_space_size=8192 node_modules/@nrwl/cli/bin/nx.js affected:build

>  NX  Running target build for projects:

  - nx9-sample

———————————————————————————————————————————————

> ng run nx9-sample:build

Expected behavior:-

> node --max_old_space_size=8192 node_modules/@nrwl/cli/bin/nx.js affected:build

>  NX  Running target build for projects:

  - nx9-sample

———————————————————————————————————————————————

> node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng.js  run nx9-sample:build

Context

Please provide any relevant information about your setup:

 @nrwl/angular : 9.2.4
  @nrwl/cli : 9.2.4
  @nrwl/cypress : 9.2.4
  @nrwl/eslint-plugin-nx : Not Found
  @nrwl/express : Not Found
  @nrwl/jest : 9.2.4
  @nrwl/linter : Not Found
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 9.2.4
  @nrwl/web : Not Found
  @nrwl/workspace : 9.2.4
  typescript : 3.8.3

Failure Logs

--- Last few GCs --->

[3223:0x2f36940] 223468 ms: Mark-sweep 1269.6 (1444.3) -> 1269.6 (1413.3) MB, 1142.4 / 0.0 ms (average mu = 0.333, current mu = 0.000) last resort GC in old space requested [3223:0x2f36940] 224623 ms: Mark-sweep 1269.6 (1413.3) -> 1269.6 (1413.3) MB, 1154.7 / 0.0 ms (average mu = 0.197, current mu = 0.000) last resort GC in old space requested

<--- JS stacktrace --->

==== JS stack trace =========================================

0: ExitFrame [pc: 0x197e04f5be1d]
1: StubFrame [pc: 0x197e04f4b476]

Security context: 0x119757e1e6c1 2: replace [0x119757e105c1](this=0x2704bd50a379 <Very long string[30764579]>,0x09cf34397d29 <JSRegExp <String[18]: [<>\/\u2028\u2029]>>,0x09cf34397dc1 <JSFunction escapeUnsafeChars (sfi = 0x36eb3d242db9)>) 3: serialize(aka serialize) [0x36eb3d243871] [/home/vsts/work/1/s/node_modules/serialize-javascript/index.js...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory 1: 0x8fb090 node::Abort() [/opt/hostedtoolcache/node/10.20.1/x64/bin/node] 2: 0x8fb0dc [/opt/hostedtoolcache/node/10.20.1/x64/bin/node] 3: 0xb031ce v8::Utils::ReportOOMFailure(v8::internal::Isolate, char const, bool) [/opt/hostedtoolcache/node/10.20.1/x64/bin/node] 4: 0xb03404 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate, char const, bool) [/opt/hostedtoolcache/node/10.20.1/x64/bin/node] 5: 0xef7462 [/opt/hostedtoolcache/node/10.20.1/x64/bin/node] 6: 0xf06c7f v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/opt/hostedtoolcache/node/10.20.1/x64/bin/node] 7: 0xed682b v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/opt/hostedtoolcache/node/10.20.1/x64/bin/node] 8: 0x10200b3 v8::internal::String::SlowFlatten(v8::internal::Handle, v8::internal::PretenureFlag) [/opt/hostedtoolcache/node/10.20.1/x64/bin/node] 9: 0xb00b74 v8::internal::String::Flatten(v8::internal::Handle, v8::internal::PretenureFlag) [/opt/hostedtoolcache/node/10.20.1/x64/bin/node] 10: 0x11a9331 v8::internal::Runtime_RegExpExecMultiple(int, v8::internal::Object*, v8::internal::Isolate) [/opt/hostedtoolcache/node/10.20.1/x64/bin/node] 11: 0x197e04f5be1d

Other

Same as - https://github.com/nrwl/nx/issues/2755

Screenshot:- image

manandkumaar commented 4 years ago

Issue got resolved after adding node max memory for nx's run-many command.

evtk commented 4 years ago

@manandkumaar can you share what you have changed exactly, since I am having the exact same issue. Thanks!

manandkumaar commented 4 years ago

@EvtK Updating the nx script in package.json as below have resolved the issue.

image

"ng": "node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng",

"nx": "node --max_old_space_size=4096 ./node_modules/@nrwl/cli/bin/nx",

evtk commented 4 years ago

@manandkumaar thanks! sadly it didn't solve my issues :(

phhien203 commented 1 year ago

@evtk this approach works for me, edit scripts in package.json file

"app-nx": "node --max-old-space-size=8192 node_modules/@nrwl/cli/bin/nx", "affected:build": "npm run app-nx affected:build -- --base=master --head=HEAD"

tini2n commented 1 year ago

same problem. package-json: "scripts": { "build": "node --max-old-space-size=8192 node_modules/@nrwl/cli/bin/nx run builder:build:production", }

github-actions[bot] commented 1 year ago

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.