Skip to content

[2.4.0][Watch] Watching causes crash in eslint fix #1084

Closed
@kyle7zhang

Description

@kyle7zhang

Error option line:

https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/typescript-estree/src/tsconfig-parser.ts#L106

What code were you trying to parse?

// Any code

tsconfig.json:

{
    "compileOnSave": true,
    "compilerOptions": {
        "target": "esnext",
        "module": "es6",
        "strict": true,
        "noImplicitAny": false,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "allowSyntheticDefaultImports": true,
        "charset": "utf8",
        "allowJs": false,
        "pretty": true,
        "lib": ["es6", "dom"],
        "noEmitOnError": false,
        "noUnusedLocals": true,
        "noUnusedParameters": true,
        "allowUnreachableCode": false,
        "allowUnusedLabels": false,
        "strictPropertyInitialization": false,
        "noFallthroughCasesInSwitch": true,
        "inlineSourceMap": true,
        "declaration": true,
        "outDir": "./lib",
        "skipLibCheck": true
    },
    "include": [
        "src",
        "types"
    ],
    "exclude": [
        "node_modules",
        "**/__tests__/*"
    ]
}

eslintrc:

module.exports = {
    root: true,
    parserOptions: {
        project: './tsconfig.json',
        // noWatch: true, // if add this option, then eslint --fix xxx.ts succeed
    },
    parser: '@typescript-eslint/parser',
    env: {
        es6: true,
        node: true,
        browser: true,
        jest: true,
    },
    extends: [
        'airbnb-base/legacy',
        'plugin:@typescript-eslint/recommended',
    ],
...

What did you expect to happen?

Can run eslint --fix without memory leak.

What actually happened?

Run command eslint --fix XXX.ts, this command still runs and the memory keeps increasing.

  eslint:cli Fix mode enabled - applying fixes +1s

<--- Last few GCs --->

[90902:0x108000000]    64687 ms: Scavenge 1317.6 (1433.7) -> 1311.2 (1438.7) MB, 7.5 / 0.0 ms  (average mu = 0.206, current mu = 0.058) allocation failure 
[90902:0x108000000]    64728 ms: Scavenge 1322.2 (1438.7) -> 1315.9 (1444.7) MB, 9.4 / 0.0 ms  (average mu = 0.206, current mu = 0.058) allocation failure 
[90902:0x108000000]    65315 ms: Mark-sweep 1326.9 (1444.7) -> 1310.7 (1443.7) MB, 559.0 / 2.0 ms  (average mu = 0.213, current mu = 0.222) allocation failure scavenge might not succeed


<--- JS stacktrace --->

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

    0: ExitFrame [pc: 0x28b71165be3d]
Security context: 0x3cd6c629e6e9 <JSObject>
    1: new Readable [0x3cd62a766339] [_stream_readable.js:~145] [pc=0x28b7128f65ef](this=0x3cd65eff6241 <Readable map = 0x3cd6d357dc49>,options=0x3cd65eff6219 <Object map = 0x3cd6d357db99>)
    2: ConstructFrame [pc: 0x28b71160d02f]
    3: StubFrame [pc: 0x28b71195bd3d]
    4: new ReaddirpStream(aka ReaddirpStream) [0x3cd6e0816fb9] [/Users/icese7en/Developer...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x10003c597 node::Abort() [/Users/icese7en/.nvm/versions/node/v10.15.3/bin/node]
 2: 0x10003c7a1 node::OnFatalError(char const*, char const*) [/Users/icese7en/.nvm/versions/node/v10.15.3/bin/node]
 3: 0x1001ad575 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/icese7en/.nvm/versions/node/v10.15.3/bin/node]
 4: 0x100579242 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/Users/icese7en/.nvm/versions/node/v10.15.3/bin/node]
 5: 0x10057bd15 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/Users/icese7en/.nvm/versions/node/v10.15.3/bin/node]
 6: 0x100577bbf v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/Users/icese7en/.nvm/versions/node/v10.15.3/bin/node]
 7: 0x100575d94 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/icese7en/.nvm/versions/node/v10.15.3/bin/node]
 8: 0x10058262c v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/Users/icese7en/.nvm/versions/node/v10.15.3/bin/node]
 9: 0x1005826af v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/Users/icese7en/.nvm/versions/node/v10.15.3/bin/node]
10: 0x100551ff4 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/Users/icese7en/.nvm/versions/node/v10.15.3/bin/node]
11: 0x1007da044 v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/Users/icese7en/.nvm/versions/node/v10.15.3/bin/node]
12: 0x28b71165be3d 
[1]    90902 abort      node ./node_modules/.bin/eslint --fix ./src/messageApi/index.ts --debug

Then add noWatch, the problem solved.

Versions

package version
@typescript-eslint/typescript-estree 2.4.0
TypeScript 3.6.4
node 10.15.3
npm 6.12.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage: typescript-estreeIssues related to @typescript-eslint/typescript-estree

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions