microsoft / vscode

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

The JS/TS language service crashed 5 times in the last 5 Minutes. #224067

Closed ImBIOS closed 3 months ago

ImBIOS commented 3 months ago

Type: Performance Issue

image

  1. Clone the repo into a public GitHub repository (or fork https://github.com/calcom/cal.com/fork). If you plan to distribute the code, keep the source code public to comply with AGPLv3. To clone in a private repository, acquire a commercial license

    git clone https://github.com/calcom/cal.com.git

    If you are on Windows, run the following command on gitbash with admin privileges:
    > git clone -c core.symlinks=true https://github.com/calcom/cal.com.git
    See docs for more details.

  2. Go to the project folder

    cd cal.com
  3. Install packages with yarn

    yarn
  4. Set up your .env file

    • Duplicate .env.example to .env
    • Use openssl rand -base64 32 to generate a key and add it under NEXTAUTH_SECRET in the .env file.
    • Use openssl rand -base64 32 to generate a key and add it under CALENDSO_ENCRYPTION_KEY in the .env file.
  5. Setup Node If your Node version does not meet the project's requirements as instructed by the docs, "nvm" (Node Version Manager) allows using Node at the version required by the project:

    nvm use

    You first might need to install the specific version and then use it:

    nvm install && nvm use

    You can install nvm from here.

  6. Edit some TS in packages, and this messages shows often.

From: TypeScript and JavaScript Language Feature

VS Code version: Code 1.91.1 (f1e16e1e6214d7c44d078b1f0607b2388f29d729, 2024-07-09T22:06:49.809Z) OS version: Windows_NT x64 10.0.22631 Modes: Remote OS version: Linux x64 6.5.0-1022-azure

System Info |Item|Value| |---|---| |CPUs|11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz (8 x 2803)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|15.79GB (3.51GB free)| |Process Argv|--open-url --crash-reporter-id e8de798a-eac6-4f68-b6a9-0bc7afa37f29 -- vscode://github.codespaces/connect?name=friendly-winner-7rq65j5vx7gfrg5v&windowId=_blank| |Screen Reader|no| |VM|0%| |Item|Value| |---|---| |Remote|Codespaces: friendly winner| |OS|Linux x64 6.5.0-1022-azure| |CPUs|AMD EPYC 7763 64-Core Processor (16 x 0)| |Memory (System)|62.78GB (49.80GB free)| |VM|0%|
Process Info ``` CPU % Mem MB PID Process 0 115 39560 code main 0 105 20428 window [3] (Issue Reporter) 0 93 20680 shared-process 0 424 23180 window [1] (README.md - cal.com [Codespaces: friendly winner] - Visual Studio Code) 0 26 29432 crashpad-handler 0 43 30552 utility-network-service 0 199 34360 gpu-process 0 282 34504 extensionHost [1] 0 82 28568 electron-nodejs (serverMain.js ) 0 82 36456 fileWatcher [1] Remote: Codespaces: friendly winner CPU % Mem MB PID Process 3 0 841 remote agent 0 0 881 extension-host 0 0 1404 /vscode/bin/linux-x64/f1e16e1e6214d7c44d078b1f0607b2388f29d729/node /home/codespace/.vscode-remote/extensions/prisma.prisma-5.17.0/node_modules/@prisma/language-server/dist/bin.js --node-ipc --clientProcessId=881 0 0 1418 /vscode/bin/linux-x64/f1e16e1e6214d7c44d078b1f0607b2388f29d729/node /home/codespace/.vscode-remote/extensions/mtxr.sqltools-0.28.3/dist/languageserver.js --node-ipc --clientProcessId=881 0 0 2092 /vscode/bin/linux-x64/f1e16e1e6214d7c44d078b1f0607b2388f29d729/node /home/codespace/.vscode-remote/extensions/graphql.vscode-graphql-0.11.0/out/server/index.js --node-ipc --clientProcessId=881 0 0 2587 /vscode/bin/linux-x64/f1e16e1e6214d7c44d078b1f0607b2388f29d729/node /home/codespace/.vscode-remote/extensions/github.vscode-github-actions-0.26.3/dist/server-node.js --node-ipc --clientProcessId=881 0 0 3050 /vscode/bin/linux-x64/f1e16e1e6214d7c44d078b1f0607b2388f29d729/node /home/codespace/.vscode-remote/extensions/dbaeumer.vscode-eslint-3.0.10/server/out/eslintServer.js --node-ipc --clientProcessId=881 0 0 3127 /vscode/bin/linux-x64/f1e16e1e6214d7c44d078b1f0607b2388f29d729/node -r /home/codespace/.vscode-remote/extensions/wallabyjs.console-ninja-1.0.332/webview/tokenizer.wasm /home/codespace/.vscode-remote/extensions/wallabyjs.console-ninja-1.0.332/out/extension/index.js 0 0 3282 /vscode/bin/linux-x64/f1e16e1e6214d7c44d078b1f0607b2388f29d729/node /vscode/bin/linux-x64/f1e16e1e6214d7c44d078b1f0607b2388f29d729/extensions/json-language-features/server/dist/node/jsonServerMain --node-ipc --clientProcessId=881 0 0 3311 /vscode/bin/linux-x64/f1e16e1e6214d7c44d078b1f0607b2388f29d729/node /home/codespace/.vscode-remote/extensions/bradlc.vscode-tailwindcss-0.12.5/dist/tailwindServer.js --node-ipc --clientProcessId=881 0 0 3795 /vscode/bin/linux-x64/f1e16e1e6214d7c44d078b1f0607b2388f29d729/node /home/codespace/.vscode-remote/extensions/stripe.vscode-stripe-3.2.2/dist/stripeLanguageServer/server.js --node-ipc --clientProcessId=881 0 0 5041 /vscode/bin/linux-x64/f1e16e1e6214d7c44d078b1f0607b2388f29d729/node /vscode/bin/linux-x64/f1e16e1e6214d7c44d078b1f0607b2388f29d729/extensions/markdown-language-features/server/dist/node/workerMain --node-ipc --clientProcessId=881 0 0 49827 /vscode/bin/linux-x64/f1e16e1e6214d7c44d078b1f0607b2388f29d729/node /home/codespace/.vscode-remote/extensions/samverschueren.linter-xo-3.20.0/dist/server.js --node-ipc --clientProcessId=881 0 0 50133 /vscode/bin/linux-x64/f1e16e1e6214d7c44d078b1f0607b2388f29d729/node --max-old-space-size=3072 /vscode/bin/linux-x64/f1e16e1e6214d7c44d078b1f0607b2388f29d729/extensions/node_modules/typescript/lib/tsserver.js --serverMode partialSemantic --useInferredProjectPerProjectRoot --disableAutomaticTypingAcquisition --cancellationPipeName /tmp/vscode-typescript1000/9e6789303b95e7068790/tscancellation-96c32a64e3895779a268.tmp* --locale en --noGetErrOnBackgroundUpdate --canUseWatchEvents --validateDefaultNpmLocation --useNodeIpc 0 0 895 fileWatcher 0 0 1331 ptyHost 0 0 1489 /usr/bin/zsh -i 0 0 42257 node /usr/share/yarn/bin/yarn.js dx 0 0 42274 /usr/local/share/nvm/versions/node/v20.15.1/bin/node /workspaces/cal.com/.yarn/releases/yarn-3.4.1.cjs dx 0 0 42307 /usr/local/share/nvm/versions/node/v20.15.1/bin/node /workspaces/cal.com/node_modules/turbo/bin/turbo run dx 0 0 42314 /workspaces/cal.com/node_modules/turbo-linux-64/bin/turbo run dx 0 0 42315 /workspaces/cal.com/node_modules/turbo-linux-64/bin/turbo --skip-infer run dx -- 0 0 42333 /workspaces/cal.com/node_modules/turbo-linux-64/bin/go-turbo {"api_client_config":{"token":null,"team_id":null,"team_slug":null,"api_url":"https://vercel.com/api","use_preflight":false,"timeout":20},"package_manager":"berry","cli_args":{"api":null,"color":false,"cpu_profile":null,"cwd":null,"heap":null,"login":null,"no_color":false,"preflight":false,"remote_cache_timeout":null,"team":null,"token":null,"trace":null,"verbosity":0,"test_run":false,"command":{"Run":{"cache_dir":null,"cache_workers":10,"concurrency":null,"continue_execution":false,"dry_run":null,"single_package":false,"filter":[],"force":null,"framework_inference":true,"global_deps":[],"graph":null,"env_mode":"Infer","ignore":[],"include_dependencies":false,"no_cache":false,"no_daemon":false,"no_deps":false,"output_logs":null,"only":false,"parallel":false,"pkg_inference_root":"","profile":null,"remote_only":false,"scope":[],"since":null,"summarize":null,"log_prefix":null,"tasks":["dx"],"pass_through_args":[],"experimental_space_id":null}}}} 0 0 47403 /usr/local/share/nvm/versions/node/v20.15.1/bin/node /workspaces/cal.com/.yarn/releases/yarn-3.4.1.cjs run dx 0 0 47432 /usr/local/share/nvm/versions/node/v20.15.1/bin/node /workspaces/cal.com/.yarn/releases/yarn-3.4.1.cjs dev 0 0 47443 /usr/local/share/nvm/versions/node/v20.15.1/bin/node /workspaces/cal.com/.yarn/releases/yarn-3.4.1.cjs dev 0 0 47457 /usr/local/share/nvm/versions/node/v20.15.1/bin/node /workspaces/cal.com/node_modules/next/dist/bin/next dev 0 0 47485 next-router-worker 0 0 23377 /usr/bin/zsh -i 0 0 23979 node /usr/share/yarn/bin/yarn.js db-studio 0 0 24017 /usr/local/share/nvm/versions/node/v20.15.1/bin/node /workspaces/cal.com/.yarn/releases/yarn-3.4.1.cjs db-studio 0 0 24053 /usr/local/share/nvm/versions/node/v20.15.1/bin/node /workspaces/cal.com/.yarn/releases/yarn-3.4.1.cjs prisma studio 0 0 24105 /usr/local/share/nvm/versions/node/v20.15.1/bin/node /workspaces/cal.com/.yarn/releases/yarn-3.4.1.cjs workspace @calcom/prisma prisma studio 0 0 24125 /usr/local/share/nvm/versions/node/v20.15.1/bin/node /workspaces/cal.com/.yarn/releases/yarn-3.4.1.cjs workspace @calcom/prisma prisma studio 0 0 24156 /usr/local/share/nvm/versions/node/v20.15.1/bin/node /workspaces/cal.com/node_modules/prisma/build/index.js studio 0 0 50233 /bin/sh -c /usr/bin/ps -ax -o pid=,ppid=,pcpu=,pmem=,command= 0 0 50234 /usr/bin/ps -ax -o pid=,ppid=,pcpu=,pmem=,command= ```
Workspace Info ``` | Remote: Codespaces: friendly winner| Folder (cal.com): 12565 files| File types: zip(3821) ts(2853) tsx(1162) svg(532) js(439) json(313) | sql(302) png(211) jpg(182) md(151) | Conf files: package.json(130) github-actions(36) tsconfig.json(29) | dockerfile(7) launch.json(1) settings.json(1) | tasks.json(1) | Launch Configs: node; ```
Extensions (126) Extension|Author (truncated)|Version ---|---|--- better-comments|aar|3.0.2 comment-tagged-templates|bie|0.3.3 vscode-translation|cai|3.0.14 es7-react-js-snippets|dsz|4.4.3 auto-close-tag|for|0.5.15 auto-rename-tag|for|0.1.10 codespaces|Git|1.17.2 remotehub|Git|0.62.0 vbnet|gor|1.0.2 vscode-graphql-syntax|Gra|1.3.6 discord-vscode|icr|5.8.0 dotenv|mik|1.0.1 remote-containers|ms-|0.375.1 remote-ssh|ms-|0.112.0 remote-ssh-edit|ms-|0.86.0 remote-wsl|ms-|0.88.2 vscode-remote-extensionpack|ms-|0.25.0 azure-repos|ms-|0.38.0 remote-explorer|ms-|0.4.3 remote-repositories|ms-|0.40.0 remote-server|ms-|1.5.2 mdc|Nux|0.2.0 material-icon-theme|PKi|5.8.0 mdx|sil|0.1.1 rewrap|stk|1.16.3 errorlens|use|3.20.0 highlight-matching-tag|vin|0.11.0 JavaScriptSnippets|xab|1.8.0 better-comments|aar|3.0.2 goto-alias|ant|0.1.6 vscode-zipfs|arc|3.0.0 comment-tagged-templates|bie|0.3.3 vscode-tailwindcss|bra|0.12.5 npm-intellisense|chr|1.4.5 path-intellisense|chr|2.9.0 vscode-markdownlint|Dav|0.55.0 vscode-eslint|dba|3.0.10 es7-react-js-snippets|dsz|4.4.3 vscode-wasm|dts|1.4.1 pug-formatter|duc|0.6.0 gitlens|eam|15.2.3 EditorConfig|Edi|0.16.4 prettier-vscode|esb|10.4.0 comment-anchors|Exo|1.10.4 vscode-expo-tools|exp|1.5.0 figma-vscode-extension|fig|0.3.5 auto-close-tag|for|0.5.15 auto-complete-tag|for|0.1.0 auto-rename-tag|for|0.1.10 shell-format|fox|7.2.5 codespaces|Git|1.17.2 copilot|Git|1.219.0 copilot-chat|Git|0.17.1 remotehub|Git|0.62.0 vscode-github-actions|git|0.26.3 vscode-pull-request-github|Git|0.92.0 go|gol|0.42.0 vbnet|gor|1.0.2 vscode-graphql|Gra|0.11.0 vscode-graphql-syntax|Gra|1.3.6 todo-tree|Gru|0.0.226 vscode-test-explorer|hbe|2.21.1 vs-code-extension|inl|1.48.3 search-node-modules|jas|1.3.0 svg|joc|1.5.4 i18n-ally|lok|2.12.0 rainbow-csv|mec|3.12.0 dotenv|mik|1.0.1 moon-console|moo|0.13.0 vscode-azureresourcegroups|ms-|0.9.1 vscode-azureterraform|ms-|0.3.2 vscode-docker|ms-|1.29.1 vscode-dotnet-runtime|ms-|2.1.1 playwright|ms-|1.1.7 pyright|ms-|1.1.373 autopep8|ms-|2024.0.0 black-formatter|ms-|2024.2.0 debugpy|ms-|2024.8.0 flake8|ms-|2023.10.0 pylint|ms-|2023.10.1 python|ms-|2024.8.1 vscode-pylance|ms-|2024.7.1 azure-account|ms-|0.12.0 azure-repos|ms-|0.38.0 cmake-tools|ms-|1.18.43 cpptools|ms-|1.7.1 cpptools-extension-pack|ms-|1.3.0 powershell|ms-|2024.2.2 remote-repositories|ms-|0.40.0 test-adapter-converter|ms-|0.1.9 gremlins|nho|0.26.0 autodocstring|njp|0.6.1 mdc|Nux|0.2.0 nuxt-vscode-extentions|Nux|0.0.6 nuxtr-vscode|Nux|0.2.16 vscode-twoslash-queries|Ort|1.2.2 bun-vscode|ove|0.0.12 material-icon-theme|PKi|5.8.0 prisma|Pri|5.17.0 project-snippets|reb|0.5.0 vscode-xml|red|0.27.1 vscode-yaml|red|1.15.0 rust-analyzer|rus|0.3.2045 gitmoji-vscode|sea|1.2.5 crates|ser|0.6.7 mdx|sil|0.1.1 autoimport|ste|1.5.4 rewrap|stk|1.16.3 vscode-stripe|str|3.2.2 even-better-toml|tam|0.19.2 tauri-vscode|tau|0.2.6 vscode-tinybird-support|Tin|1.0.3 vsfire|tob|1.4.1 vscode-status-bar-format-toggle|tom|3.2.0 cmake|twx|0.0.17 errorlens|use|3.20.0 vscode-lldb|vad|1.10.0 highlight-matching-tag|vin|0.11.0 vscode-wakatime|Wak|24.6.0 JavaScriptSnippets|xab|1.8.0 clang-format|xav|1.9.0 vscode-mdx-preview|xyc|0.3.3 luahelper|yin|0.2.29 pretty-ts-errors|Yoa|0.5.4 markdown-all-in-one|yzh|3.6.2 vscode-zig|zig|0.5.8 (5 theme extensions excluded)
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492:30256859 vscod805cf:30301675 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonnoceb:30805159 asynctok:30898717 pythonregdiag2:30936856 pythonmypyd1:30879173 2e7ec940:31000449 pythontbext0:30879054 accentitlementsc:30995553 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 dsvsc021:30996838 bdiig495:31013172 pythoncenvpt:31062603 a69g1124:31058053 dvdeprecation:31068756 dwnewjupyter:31046869 2f103344:31071589 impr_priority:31102340 refactort:31101459 ccplc:31103425 pythonrstrctxt:31103193 ```
ImBIOS commented 3 months ago

Found the problem and solution:

Problem

󰀵  󱑍 09:53  ﱮ cal-com    main !?+787 via  v18.20.3   3s 
 ✗  node -e 'console.log(v8.getHeapStatistics().heap_size_limit/(1024*1024))'

2096

󰀵  󱑍 09:53  ﱮ cal-com    main !?+787 via  v18.20.3 
 ➜  yarn tsc --pretty --noEmit packages/core/EventManager.test.ts 

<--- Last few GCs --->

[63836:0x673f8b0]    71923 ms: Scavenge (reduce) 2042.8 (2082.0) -> 2041.9 (2082.2) MB, 7.7 / 0.0 ms  (average mu = 0.138, current mu = 0.007) allocation failure; 
[63836:0x673f8b0]    72849 ms: Mark-sweep (reduce) 2042.9 (2082.2) -> 2041.2 (2082.2) MB, 910.3 / 0.0 ms  (average mu = 0.151, current mu = 0.164) allocation failure; scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0xb9c310 node::Abort() [/home/username/.proto/tools/node/18.20.3/bin/node]
 2: 0xaa27ee  [/home/username/.proto/tools/node/18.20.3/bin/node]
 3: 0xd73eb0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/home/username/.proto/tools/node/18.20.3/bin/node]
 4: 0xd74257 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/home/username/.proto/tools/node/18.20.3/bin/node]
 5: 0xf515d5  [/home/username/.proto/tools/node/18.20.3/bin/node]
 6: 0xf524d8 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/home/username/.proto/tools/node/18.20.3/bin/node]
 7: 0xf629d3  [/home/username/.proto/tools/node/18.20.3/bin/node]
 8: 0xf63848 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/home/username/.proto/tools/node/18.20.3/bin/node]
 9: 0xf3e19e v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/home/username/.proto/tools/node/18.20.3/bin/node]
10: 0xf3f567 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/home/username/.proto/tools/node/18.20.3/bin/node]
11: 0xf2076a v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/home/username/.proto/tools/node/18.20.3/bin/node]
12: 0x12e599f v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/home/username/.proto/tools/node/18.20.3/bin/node]
13: 0x17125f9  [/home/username/.proto/tools/node/18.20.3/bin/node]

Solution

# Increase nodejs memory limit
export NODE_OPTIONS="--max-old-space-size=4096"

You can place this in your shell config like ~/.zshrc to run each startup.

Reference: