microsoft / vscode-eslint

VSCode extension to integrate eslint into VSCode
MIT License
1.74k stars 335 forks source link

ESlint server crashes when passing custom "parserOptions.project" config file #1675

Closed charlie632 closed 1 year ago

charlie632 commented 1 year ago

I'm trying to use a couple of ESlint rules that required me to pass parserOptions.project to the ESlint config. Whenever I add that option to ESLint, the server automatically crashes, but when I comment the parserOptions object, it works as expected.

As additional notes, I can run ESLint without any issue via CLI, this is only happening in the VSCode Extension Server.

Libs:

This is the ESLint config inside the package:

// .eslintrc.js
module.exports = {
  parserOptions: {
    project: ['./tsconfig.json'],
  },
  rules: {
    // '@typescript-eslint/no-floating-promises': 'error',
    // '@typescript-eslint/await-thenable': 'error',
    // '@typescript-eslint/no-misused-promises': 'error',
  },
};

and this is the ESLint at the root of the monorepo

module.exports = {
  root: true,
  parser: '@typescript-eslint/parser',
  ignorePatterns: ['node_modules/*', 'packages/*/dist/*'],
  extends: [
    'eslint:recommended',
    'plugin:@typescript-eslint/recommended',
    'prettier', // Prettier should be the last so it can override other configs
  ],
  plugins: [
    '@typescript-eslint',
    'literal-checker',
    // Please don't use eslint-plugin-prettier, the formatting rules are owned by prettier
  ],
  env: {
    browser: true,
    node: true,
    jasmine: true,
    jest: true,
  },
  rules: {
    '@typescript-eslint/explicit-function-return-type': 'off',
    '@typescript-eslint/explicit-module-boundary-types': 'off',
    '@typescript-eslint/interface-name-prefix': 'off',
    '@typescript-eslint/no-unused-vars': [
      'error',
      { argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
    ],
    '@typescript-eslint/ban-types': 'off',
    // eslint-disable-next-line literal-checker/literal-check
    'literal-checker/literal-check': [2, ['company.com', 'company-dev.com'], []],
  },
};

and the tsconfig.json

{
  "compilerOptions": {
    "outDir": "./dist",
    "noEmitHelpers": false,
    "target": "ES6",
    "sourceMap": true,
    "declaration": true,
    "lib": ["es2019", "dom", "dom.iterable"],
    "module": "commonjs",
    "jsx": "react",
    "moduleResolution": "node",
    "strict": true,
    "esModuleInterop": true,
    "allowJs": false,
    "forceConsistentCasingInFileNames": true,
    "skipLibCheck": true
  },
  "exclude": ["dist", "node_modules"]
}

VSCode Eslint Server Output


<--- Last few GCs --->

[23947:0x100007b0000]    37777 ms: Scavenge 3936.0 (4053.6) -> 3931.9 (4056.1) MB, 3.4 / 0.0 ms  (average mu = 0.957, current mu = 0.962) allocation failure; 
[23947:0x100007b0000]    38210 ms: Scavenge 3938.1 (4056.1) -> 3934.0 (4056.9) MB, 424.7 / 0.0 ms  (average mu = 0.957, current mu = 0.962) allocation failure; 
[23947:0x100007b0000]    38226 ms: Scavenge 3939.9 (4056.9) -> 3936.1 (4056.9) MB, 8.1 / 0.0 ms  (average mu = 0.957, current mu = 0.962) allocation failure; 

<--- JS stacktrace --->

FATAL ERROR: NewSpace::Rebalance Allocation failed - JavaScript heap out of memory
 1: 0x11678cb1c node::FatalException(v8::Isolate*, v8::TryCatch const&) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 2: 0x11678cc2c node::OnFatalError(char const*, char const*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 3: 0x11187deec v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 4: 0x11187de2c v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 5: 0x111a34c88 v8::internal::EmbedderStackStateScope::EmbedderStackStateScope(v8::internal::Heap*, v8::internal::EmbedderStackStateScope::Origin, cppgc::EmbedderStackState) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 6: 0x111a58228 v8::internal::MarkCompactCollector::IsMapOrForwarded(v8::internal::Map) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 7: 0x111a54934 v8::internal::MarkCompactCollector::IsMapOrForwarded(v8::internal::Map) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 8: 0x111a37f18 v8::internal::Heap::EnsureWasmCanonicalRttsSize(int) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 9: 0x111a34ff4 v8::internal::EmbedderStackStateScope::~EmbedderStackStateScope() [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
10: 0x111a32e90 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
11: 0x111a2a8ac v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
12: 0x111a2b520 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
13: 0x111a09da0 v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
14: 0x111e0f4b4 v8::internal::Runtime::GetInternalProperties(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
15: 0x13197f16f6c 
16: 0x131948b1d8c 
17: 0x131948a5ed4 
18: 0x13197f2f73c 
19: 0x131948a199c 
20: 0x131948aaaf4 
21: 0x13197f2f73c 
22: 0x13197e8c9c4 
23: 0x13197e8c9c4 
24: 0x13197e8c9c4 
25: 0x13197e8c9c4 
26: 0x13197e8c9c4 
27: 0x13197e8c9c4 
28: 0x13197e8c9c4 
29: 0x13197e8c9c4 
30: 0x13197e8c9c4 
31: 0x13197e8c9c4 
32: 0x13197e8c9c4 
33: 0x13197e8c9c4 
34: 0x13197e8c9c4 
35: 0x13197e8c9c4 
36: 0x13197e8c9c4 
37: 0x13197e8c9c4 
38: 0x13197e8c9c4 
39: 0x13197e8c9c4 
40: 0x13197e8c9c4 
41: 0x13197e8c9c4 
42: 0x13197e8c9c4 
43: 0x13197e8c9c4 
44: 0x13197e8c9c4 
45: 0x13197e8c9c4 
46: 0x13197ec5cb4 
47: 0x13197f6dbd8 
48: 0x13197eb4aa4 
49: 0x13197e8ab48 
50: 0x1119af7f8 v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
51: 0x1119b02dc v8::internal::Execution::TryCallScript(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::FixedArray>, v8::internal::Execution::MessageHandling, v8::internal::MaybeHandle<v8::internal::Object>*, bool) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
52: 0x1119b044c v8::internal::Execution::TryCall(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*, v8::internal::Execution::MessageHandling, v8::internal::MaybeHandle<v8::internal::Object>*, bool) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
53: 0x1119dbee0 v8::internal::MicrotaskQueue::PerformCheckpointInternal(v8::Isolate*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
54: 0x1166f4574 node::CallbackScope::~CallbackScope() [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
55: 0x1166f4894 node::CallbackScope::~CallbackScope() [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
56: 0x1166f4c0c node::MakeCallback(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
57: 0x11673c624 node::EmitAsyncDestroy(node::Environment*, node::async_context) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
58: 0x110a601bc uv_check_start [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
59: 0x110a5ae94 uv_run [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
60: 0x1166f5170 node::SpinEventLoop(node::Environment*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
61: 0x110c2ea48 node::FreeArrayBufferAllocator(node::ArrayBufferAllocator*) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
62: 0x110a6c184 ElectronInitializeICUandStartNode [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
63: 0x1924c7f28 start [/usr/lib/dyld]
MariaSolOs commented 1 year ago

Could you try setting the tsconfigRootDir as indicated in the typescript-eslint docs?

dbaeumer commented 1 year ago

The crash occurs because of an out of memory exception. In general the heap in Node is limited to 4GB and depending on the Electron version used in VS Code this can't be increased (https://github.com/electron/electron/issues/31330). What you can do to lift the memory is:

charlie632 commented 1 year ago

@MariaSolOs upgrading to

    "@typescript-eslint/eslint-plugin": "^5.60.1",
    "@typescript-eslint/parser": "^5.60.1",

and following the docs did it!

Thanks.

MariaSolOs commented 1 year ago

@charlie632 glad you made it work! Setting up typescript-eslint can be really tricky sometimes...

charlie632 commented 1 year ago

@MariaSolOs yeah, it is ☹️! Thanks for the help!