@nrwl/linter: heap error when linting 2800+ files
See original GitHub issueExpected Behavior
lint should work consistently no matter if executed via linter builder or directly via eslint cli
Current Behavior
with following workspace configuration
{
"pb-legacy": {
"root": "src",
"sourceRoot": "src/js",
"projectType": "library",
"schematics": {},
"architect": {
"lint-broken": {
"builder": "@nrwl/linter:lint",
"options": {
"linter": "eslint",
"config": ".eslintrc-pb-legacy",
"tsConfig": ["tsconfig.eslint.pb-legacy.json"],
"exclude": ["**/node_modules/**", "!src/js/**"]
}
},
"lint": {
"builder": "@nrwl/workspace:run-commands",
"options": {
"commands": [
{
"command": "eslint --ext .js,.ts,.tsx --config .eslintrc-pb-legacy src/js"
}
]
}
}
}
}
- 🚨
yarn nx run pb-legacy:lint-broken
throw error because of out of memory
<--- Last few GCs --->
[41332:0x103b12000] 79269 ms: Scavenge 1362.1 (1423.2) -> 1361.2 (1423.7) MB, 2.5 / 0.0 ms (average mu = 0.341, current mu = 0.292) allocation failure
[41332:0x103b12000] 79276 ms: Scavenge 1362.1 (1423.7) -> 1361.2 (1424.2) MB, 2.7 / 0.0 ms (average mu = 0.341, current mu = 0.292) allocation failure
[41332:0x103b12000] 79283 ms: Scavenge 1362.4 (1424.2) -> 1361.8 (1425.2) MB, 2.8 / 0.0 ms (average mu = 0.341, current mu = 0.292) allocation failure
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x101e4d4dbe3d]
1: StubFrame [pc: 0x101e4e52d6cd]
Security context: 0x31dba791e6e9 <JSObject>
2: /* anonymous */(aka /* anonymous */) [0x31db3fcce2d1] [/Users/hotell/Projects/devel/productboard/pb-frontend/node_modules/eslint/lib/linter/linter.js:1] [bytecode=0x31dbccfcb971 offset=0](this=0x31db56a026f1 <undefined>,ruleId=0x31dbcd459771 <String[17]: constructor-super>)
3: arguments adaptor frame: 3->1
...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x10096d6b6 node::Abort() (.cold.1) [/usr/local/Cellar/node@10/10.18.1/bin/node]
2: 0x10003b9e6 node_module_register [/usr/local/Cellar/node@10/10.18.1/bin/node]
3: 0x10003bba7 node::OnFatalError(char const*, char const*) [/usr/local/Cellar/node@10/10.18.1/bin/node]
few debug logs from builder:
nx run pb-legacy:lint-broken
builder options:
{
linter: 'eslint',
config: '.eslintrc-pb-legacy',
tsConfig: [ 'tsconfig.eslint.pb-legacy.json' ],
exclude: [ '**/node_modules/**', '!src/js/**' ],
format: 'stylish',
files: [],
force: false,
silent: false,
fix: false,
cache: false,
cacheLocation: undefined,
outputFile: undefined
}
Linting "pb-legacy"...
- eslintConfigPath: '/Users/hotell/Projects/devel/my-project/.eslintrc-pb-legacy',
- tsConfigs: [ 'tsconfig.eslint.pb-legacy.json' ]
- filesCount: 2839
- ✅
yarn nx run pb-legacy:lint
properly lints codebase
Context
@nrwl/angular : Not Found
@nrwl/cli : 9.1.2
@nrwl/cypress : 9.1.2
@nrwl/eslint-plugin-nx : 9.1.2
@nrwl/express : Not Found
@nrwl/jest : 9.1.2
@nrwl/linter : 9.1.2
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : 9.1.2
@nrwl/react : 9.1.2
@nrwl/schematics : Not Found
@nrwl/tao : 9.1.2
@nrwl/web : 9.1.2
@nrwl/workspace : 9.1.2
typescript : 3.8.3
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:11 (2 by maintainers)
Top Results From Across the Web
How to increase EsLint memory to avoid `JavaScript heap ...
The problem is that trying to run EsLint on this file results in a JavaScript heap out of memory error. $ eslint app.js...
Read more >Confluence crashes due to 'OutOfMemoryError Java heap ...
Cause. The Java heap space allocation has been exceeded. This can happen either from a memory leak in the application or from normal...
Read more >JavaScript Heap Out Of Memory Error
A quick solution that you can use to fix "Heap Out Of Memory Error" in JavaScript. We lay out the causes and how...
Read more >Error: OutOfMemoryError: Java heap space
If you download more than 1 millions files and do not increase the heap memory, you will run out of heap memory. Resolution....
Read more >The 4 general reasons for OutOfMemoryError errors and ...
Heapdump - a binary format debugging document with a representation of the Java heap. Javacore – a text format debugging file that comes...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have also experienced this error and finally came up with a solution. The problem origin from how TypeScript and ESLint works together, providing the files to lint.
When creating a new workspace with Nx everything works, since there are limited number of files to lint. As the code base grows this will eventually become a problem.
Suggested fix
To support enterprise workspaces I did the following:
Created a new file
tsconfig.eslint.json
containing a reference totsconfig.base.json
and the paths that should support linting. For a default Nx workspace, paths would beapps
andlibs
.Then change
parserOptions
in.eslintrc
to point to the new file.The lint block in
angular.json
should also look something like this.Now everything should work as expected. Hopefully it will help someone else struggling getting it to work.
Context
Nx version
10.0.12
.Finally
Kudos to this issue that got me on track by explaining the problem in more detail.
@daton89 sorry, we transitioned from github docs to a full website: https://typescript-eslint.io/docs/linting/troubleshooting#my-linting-feels-really-slow