microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.49k stars 29.37k forks source link

code helper 100% because of typescript-language-features #55070

Closed macrozone closed 6 years ago

macrozone commented 6 years ago

Code Helper drives me crazy with using 100% cpu in some projects.

It does not always happen, but i think it is related to large projects. I tried to add all big folders (node_modules, some build folder, meteor local folder) to files.exclude, files.watcherExclude and search.exclude, but with no luck.

Grepping the amok helper reveals:

/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/out/utils/electronForkStart.js /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName /var/folders/8h/pr6752ps02b1pg638btj4cbc0000gp/T/vscode-tscancellation-667e5036c3ac0c42672e.sock* --globalPlugins typescript-styled-plugin --pluginProbeLocations /Users/macrozone/.vscode/extensions/jpoissonnier.vscode-styled-components-0.0.21 --locale de --noGetErrOnBackgroundUpdate

I don't use typescript in that project (using flow here)

Steps to Reproduce:

  1. have some large build folder in your project
  2. open vscode
mjbvz commented 6 years ago

Does this reproduce in the latest VS Code insiders build?

Also, try configuring a jsconfig.json file with the exclude setting to exclude the node_modules and build files from intellisense

vscodebot[bot] commented 6 years ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

macrozone commented 6 years ago

@mjbvz i did not try to run it with latest vscode yet, but i can give it a try. Can you provide a link to the issue that has been fixed in the latest vscode insiders build?

Is it possible to add this configuration to vscode user settigs? Having a jsconfig.json seems to be very non-standard to me (first time i see that)

mjbvz commented 6 years ago

Yes please test in insider. I don't have enough information about the issue to know what is could be a duplicate of

jsconfig is our approach for specifying js projects. It is used by the js/ts plugins for sublime, atom, and vs as well

maxkomarychev commented 6 years ago

same thing happened to me. still hapenning with code-insiders. after disabling extension for styled-components I have this:

USERNAME              95652  99.6  2.7  5480312 447872   ??  R     2:30PM   1:58.61 /Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Code - Insiders Helper.app/Contents/MacOS/Code - Insiders Helper /Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/typescript-language-features/out/utils/electronForkStart.js /Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName /var/folders/6t/1631xl2568nbpqr5g0_0xly80000gn/T/vscode-typescript/tscancellation-7f17a37a2bb6ca1fcd5a.tmp* --locale en --noGetErrOnBackgroundUpdate
USERNAME              96905   0.0  0.0  4276984    924 s002  S+    2:32PM   0:00.00 grep 95652
maxkomarychev commented 6 years ago

Also this still an issue after I updated my jsconfig with exclude.

id0Sch commented 6 years ago

Mac OSX 10.13.3 (17D47) Version: 1.26.0-insider (1.26.0-insider) - but its happening for about 8 months... File 200+ lines in a medium+- TS project - any change / autocomplete /save causes 99% CPU FOREVER.


Adding a jsconfig that is identical to my tsconfig just without the ts specific stuff solved the issue on a 100% reproducible file... I will try to use vscode again (had to stop since it was impossible to use...) and report back 👍

@maxkomarychev thanks for commenting in #51776 !

maxkomarychev commented 6 years ago

@id0Sch hey, could you please share your tsconfig/jsconfig which solved the issue for you?

Thanks.

id0Sch commented 6 years ago

there's probably alot of useless stuff in there but here you go.

tsconfig

{
  "compilerOptions": {
    "sourceMap": true,
    "noImplicitAny": false,
    "noUnusedLocals": true,
    "allowSyntheticDefaultImports": true,
    "forceConsistentCasingInFileNames": true,
    "noUnusedParameters": true,
    "removeComments": false,
    "moduleResolution": "node",
    "outDir": "./dist/",
    "module": "esnext",
    "target": "es5",
    "jsx": "react",
    "allowJs": true,
    "lib": [
      "dom",
      "es5",
      "es6",
      "es2015",
      "es2016",
      "es2017.object"
    ],
    "baseUrl": "./src",
  },
  "include": [
    "./src/**/*.ts*"
  ],
  "exclude": [
    "**/node_modules/**",
    "**/webpack_cache/**",
    "**/dist/**"
  ]
}

jsconfig

{
  "compilerOptions": {
    "sourceMap": true,
    "noImplicitAny": false,
    "noUnusedLocals": true,
    "allowSyntheticDefaultImports": true,
    "forceConsistentCasingInFileNames": true,
    "noUnusedParameters": true,
    "removeComments": false,
    "moduleResolution": "node",
    "outDir": "./dist/",
    "module": "es6",
    "target": "es5",
    "jsx": "react",
    "lib": [
      "dom",
      "es5",
      "es6",
      "es2015",
      "es2016",
      "es2017.object"
    ],
    "baseUrl": "./src"
  },
  "include": [
    "./src/**/*.js*"
  ],
  "exclude": [
    "**/node_modules/**",
    "**/webpack_cache/**",
    "**/dist/**"
  ]
}

and thats my usersettings.json for vscode itself

{
    "window.zoomLevel": 0,
    "search.exclude": {
        "**/node_modules": true,
        "**/node_modules/**": true,
        "**/bower_components": true,
        "**/dist/**": true,
        "**/github.com": true,
        "**/golang.org": true
    },
    "eslint.run": "onSave",
    "eslint.autoFixOnSave": true,
    "files.autoSave": "afterDelay",
    "javascript.format.insertSpaceBeforeFunctionParenthesis": true,
    "typescript.format.insertSpaceBeforeFunctionParenthesis": true,
    "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
    "typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
    "typescript.format.insertSpaceAfterConstructor": true,
    "javascript.format.insertSpaceAfterConstructor": true,
    "diffEditor.ignoreTrimWhitespace": false,
    "files.exclude": {
        "/.git": true,
        "/.svn": true,
        "/.hg": true,
        "/CVS": true,
        "/.DS_Store": true,
        "**/dist/**": true,
        "/node_modules": true,
        "/node_modules/": true,
        "**/node_modules/**": true,
        "**/webpack_cache/**": true,
    },
    "files.watcherExclude": {
        "/.git": true,
        "/.svn": true,
        "/.hg": true,
        "/CVS": true,
        "/.DS_Store": true,
        "**/dist/**": true,
        "/node_modules": true,
        "**/node_modules/**": true,
        "**/webpack_cache/**": true,
        "**/.git/objects/**": true,
        "**/tmp/**": true,
        "/node_modules/": true,
        "**/*.gzip": true
    },
    "files.useExperimentalFileWatcher": false,
    "editor.formatOnSave": false, //TODO:change back
    "workbench.colorTheme": "Darcula",
    "explorer.confirmDragAndDrop": false,
    "editor.tabSize": 2,
    "npm.packageManager": "yarn",
    "grunt.autoDetect": "off",
    "json.schemas": [
        {
            "fileMatch": [
                "**/manifest.json"
            ],
            "url": "http://json.schemastore.org/chrome-manifest"
        }
    ],
    "workbench.editor.enablePreview": true,
    "editor.fontLigatures": true,
    "editor.fontFamily": "'Fira Code'",
    "emmet.showAbbreviationSuggestions": false,
    "emmet.optimizeStylesheetParsing": false,
    "emmet.excludeLanguages": [
        "markdown",
        "javascript",
        "javascriptreact",
        "typescript",
        "typescriptreact",
        "*"
    ],
    "eslint.packageManager": "yarn",
    "eslint.validate": [
        {
            "language": "javascript",
            "autoFix": true
        },
        {
            "language": "javascriptreact",
            "autoFix": true
        },
        {
            "language": "typescript",
            "autoFix": true
        },
        {
            "language": "typescriptreact",
            "autoFix": true
        }
    ],
    "git.autofetch": false,
    "typescript.updateImportsOnFileMove.enabled": "always",
    "gitlens.advanced.messages": {
        "suppressShowKeyBindingsNotice": true
    },
    "breadcrumbs.enabled": true,
    "git.enabled": true,
    "typescript.tsserver.log": "verbose",    
}
maxkomarychev commented 6 years ago

Thanks,

tried with yours both jsconfig and tsconfig. CPU usage dropped only to ~50%.

Interestingly enough, when I use the following files (provided below) I have the same effect of "Code Helper" hanging around 50%. None of the files have exclude specifier, also tsconfig is completely empty. I achieved 50% drop by simply adding empty tsconfig.json

jsconfig

{
    "compilerOptions": {
        "target": "ES6",
        "module": "commonjs",
        "allowSyntheticDefaultImports": true,
        "experimentalDecorators": true,
        "baseUrl": "./",
        "paths": {
            "app/*": ["src/*"]
        }
    }
}

tsconfig

{}
id0Sch commented 6 years ago

So I kept working and I still get 100% CPU even with the jsconfig :\

jvineveld commented 6 years ago

same issue here, but with ES6 JS in a create-react-app setting. Project isn't even that big yet, around 20components, but i keep getting 100% CPU usage after a while.

I've excluded the node_module, build, .git, etc. folders, still same thing. After a while the code color formatting is breaking, 'tab' isn't working anymore, the whole application gets sluggish and un-responsive.

Today the battery of my MBP started at 20%, while charging, dropped to 5% because of code helper having a hard time.. (In activity monitor it was clear CodeHelper was using all the power and CPU, took around 3 hours)

Just stating this so it's clear this issue is a real thing,..

makandz commented 6 years ago

Don't know if this is related, but it's not only Code Helper that does this. I've also experienced Chrome's helper spike up to 95 - 100% CPU usage sometimes when refreshing the project I am working on.

macrozone commented 6 years ago

i configured a jsconfig.json file with

{
  "exclude": ["node_modules", ".meteor"]
}

but it does not make any difference. typescript-language-feature and tsserver.js still going amok. I don't use typescript!