nrwl / nx

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

Running nx lint --fix fails with max call stack or JS heap out of memory #7894

Closed yharaskrik closed 2 years ago

yharaskrik commented 2 years ago

Current Behavior

Running nx lint --fix on a library either runs into Maximum call stack error (angular lib) or JavaScript heap out of memory error (node lib)

Angular lib has type aware checking enabled in the tsconfig Angular lib: image

Node lib: image

Also seems to not work without the --fix flag

Expected Behavior

Should be able to lint and fix

Steps to Reproduce

Upgrade to v13 and run linting

This issue may not be prioritized if details are not provided to help us reproduce the issue.

Failure Logs

> nx run type-affiliate:lint --fix 

Linting "type-affiliate"...

<--- Last few GCs --->

[42108:0x102d83000]    91920 ms: Mark-sweep 4093.4 (4102.0) -> 4092.8 (4102.0) MB, 2510.0 / 0.0 ms  (average mu = 0.057, current mu = 0.003) allocation failure scavenge might not succeed
[42108:0x102d83000]    94563 ms: Mark-sweep 4093.7 (4102.0) -> 4093.1 (4102.2) MB, 2635.5 / 0.0 ms  (average mu = 0.029, current mu = 0.003) allocation failure scavenge might not succeed

<--- JS stacktrace --->

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

    0: ExitFrame [pc: 0x100a04099]
    1: StubFrame [pc: 0x100a6fc03]
Security context: 0x22c83b4808d1 <JSObject>
    2: bindForInOrForOfStatement(aka bindForInOrForOfStatement) [0x22c89d7b4959] [/Users/jaybell/WebstormProjects/trellis-mono/node_modules/typescript/lib/typescript.js:43459] [bytecode=0x22c9450b7bf9 offset=197](this=0x22c8db7804b1 <undefined>,0x22c8983b2379 <NodeObject map = 0x22c8a915f339>)
    3: bindChildren(aka bindChild...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x1011f7a65 node::Abort() (.cold.1) [/Users/jaybell/.nvm/versions/node/v12.22.5/bin/node]
 2: 0x1000a5fd9 node::Abort() [/Users/jaybell/.nvm/versions/node/v12.22.5/bin/node]
 3: 0x1000a613f node::OnFatalError(char const*, char const*) [/Users/jaybell/.nvm/versions/node/v12.22.5/bin/node]
 4: 0x1001efb57 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/Users/jaybell/.nvm/versions/node/v12.22.5/bin/node]
 5: 0x1001efaf7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/jaybell/.nvm/versions/node/v12.22.5/bin/node]
 6: 0x100386445 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/Users/jaybell/.nvm/versions/node/v12.22.5/bin/node]
 7: 0x100387c9a v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/Users/jaybell/.nvm/versions/node/v12.22.5/bin/node]
 8: 0x10038471e v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/Users/jaybell/.nvm/versions/node/v12.22.5/bin/node]
 9: 0x1003824d0 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/jaybell/.nvm/versions/node/v12.22.5/bin/node]
10: 0x10038e2fa v8::internal::Heap::AllocateRawWithLightRetry(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/jaybell/.nvm/versions/node/v12.22.5/bin/node]
11: 0x10038e381 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/jaybell/.nvm/versions/node/v12.22.5/bin/node]
12: 0x10035d62c v8::internal::Factory::NewFeedbackVector(v8::internal::Handle<v8::internal::SharedFunctionInfo>, v8::internal::Handle<v8::internal::ClosureFeedbackCellArray>, v8::internal::AllocationType) [/Users/jaybell/.nvm/versions/node/v12.22.5/bin/node]
13: 0x1005198d9 v8::internal::FeedbackVector::New(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SharedFunctionInfo>, v8::internal::Handle<v8::internal::ClosureFeedbackCellArray>) [/Users/jaybell/.nvm/versions/node/v12.22.5/bin/node]
14: 0x10055a6f5 v8::internal::JSFunction::EnsureFeedbackVector(v8::internal::Handle<v8::internal::JSFunction>) [/Users/jaybell/.nvm/versions/node/v12.22.5/bin/node]
15: 0x1006ab93a v8::internal::Runtime_BytecodeBudgetInterrupt(int, unsigned long*, v8::internal::Isolate*) [/Users/jaybell/.nvm/versions/node/v12.22.5/bin/node]
16: 0x100a04099 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/Users/jaybell/.nvm/versions/node/v12.22.5/bin/node]
> nx run shared-feature-donor-auth:lint --fix 

Linting "shared-feature-donor-auth"...
Maximum call stack size exceeded
Occurred while linting /Users/jaybell/WebstormProjects/trellis-mono/libs/shared/feature/donor-auth/src/lib/dialog/donor-auth-dialog.component.spec.ts:1

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

>  NX   ERROR  Running target "shared-feature-donor-auth:lint" failed

  Failed tasks:

  - shared-feature-donor-auth:lint

  Hint: run the command with --verbose for more details.

Environment

>  NX  Report complete - copy this into the issue template

  Node : 12.22.5
  OS   : darwin x64
  yarn : 1.22.17

  nx : 13.2.2
  @nrwl/angular : 13.2.2
  @nrwl/cli : 13.2.2
  @nrwl/cypress : 13.2.2
  @nrwl/devkit : 13.2.2
  @nrwl/eslint-plugin-nx : 13.2.2
  @nrwl/express : 13.2.2
  @nrwl/jest : 13.2.2
  @nrwl/linter : 13.2.2
  @nrwl/nest : 13.2.2
  @nrwl/next : undefined
  @nrwl/node : 13.2.2
  @nrwl/nx-cloud : 12.5.4
  @nrwl/react : undefined
  @nrwl/react-native : undefined
  @nrwl/schematics : undefined
  @nrwl/tao : 13.2.2
  @nrwl/web : 13.2.2
  @nrwl/workspace : 13.2.2
  @nrwl/storybook : 13.2.2
  @nrwl/gatsby : undefined
  typescript : 4.4.4
  rxjs : 7.4.0
  ---------------------------------------
  Community plugins:
         @angular-material-extensions/google-maps-autocomplete: 6.2.1
         @angular-material-extensions/password-strength: 8.2.1
         @angular/animations: 13.0.2
         @angular/cdk: 13.0.2
         @angular/cli: 13.0.3
         @angular/common: 13.0.2
         @angular/compiler: 13.0.2
         @angular/core: 13.0.2
         @angular/fire: 6.1.4
         @angular/forms: 13.0.2
         @angular/material: 13.0.2
         @angular/platform-browser: 13.0.2
         @angular/platform-browser-dynamic: 13.0.2
         @angular/platform-server: 13.0.2
         @angular/router: 13.0.2
         @angular/service-worker: 13.0.2
         @angular/youtube-player: 13.0.2
         @ngneat/spectator: 9.0.0
         @ngrx/component: 13.0.1
         @ngrx/component-store: 13.0.1
         @ngrx/data: 13.0.1
         @ngrx/effects: 13.0.1
         @ngrx/entity: 13.0.1
         @ngrx/router-store: 13.0.1
         @ngrx/schematics: 13.0.1
         @ngrx/store: 13.0.1
         @ngrx/store-devtools: 13.0.1
         @nguniversal/builders: 13.0.1
         @nguniversal/common: 13.0.1
         @nguniversal/express-engine: 13.0.1
         apollo-angular: 2.6.0
         ngx-bootstrap: 5.5.0
         @angular-devkit/build-angular: 13.0.3
         @angular/compiler-cli: 13.0.2
         @angular/language-service: 13.0.2
         @nx-aws-plugin/nx-aws-cache: 0.0.4
         @storybook/angular: 6.4.0-rc.7

Tried with @typescript-eslint v4 (the version Nx installed) as well as v5, no dice.

Fully doesn't work with eslint v8

Coly010 commented 2 years ago

Hey! Can you provide a repo that produces this error so that I can investigate it further?

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

NotSoImportant commented 2 years ago

Hi, we are still having the issue in our 13.1.3 environment. We are currently struggeling with upgrading due to several other nx issues (mainly cache calculation). We hope we can get the upgrade through with 13.7.1 now and will re-check again. Please un-stale.

Coly010 commented 2 years ago

@NotSoImportant would you be able to provide a reproduction so that we can investigate this further?

NotSoImportant commented 2 years ago

Hi, as this happens in a private repo / server I will try my best to create a public repo and provide it here.

Coly010 commented 2 years ago

Thanks!

daton89 commented 2 years ago

I had the same issue in my workspace, after a very long investigation I've noticed that eslint runs multiple times per each tsconfig file you have in your lib. Currently eslint doesn't support tsconfig references and Nx defines by default different tsconfig for lib and specs and when you define parserOptions.project with the wildcard then multiple compiler are created and if you have a wide codebase to scan in your tsconfig includes you end up is slow or not ending programs. If you want to solve the problem you can try using a single tsconfig file for lib and specs.

NotSoImportant commented 2 years ago

Thank you @daton89. Let me check if this is also the case here.

NotSoImportant commented 2 years ago

Thanks @daton89 for this hint. Problem is solved after removing the following config from every .eslintrc.json → "overrides" section

"parserOptions": {
  "project": "./tsconfig.*?.json"     // or different paths here
},
meeroslav commented 2 years ago

Glad you solved it @NotSoImportant

Indeed, that section should not exist in your .eslintrc.json.

@yharaskrik did any of this help you? If not, please try to provide a minimal reproduction so we can investigate further.

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.