microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.08k stars 12.37k forks source link

Typescript Intellisense and Auto Suggestion stuck at loading #54459

Closed seyaobey-dev closed 1 month ago

seyaobey-dev commented 1 year ago

Type: Performance Issue

When I hover over a variable name or I press "ctrl + cmd" to see the suggestions, typescript displays a "loading" tooltip for several minutes before just failing to display suggestions. Sometimes also, on the bottom bar, the "loading IntelliSense status" message takes several minutes to complete. In the meaning time, any typescript related functionality is non working.

I would like to mention that this behaviour appears only in a nextjs 13 (app router) project which contains a huge .d.ts file (more than 30 000 lines). But I don't observer this behaviour in any other non nextjs project. (For example the same huge file works just fine in a react-native expo project).

I tried the Insiders build, tried to uninstall all extensions, tried to downgrade to several lower versions...

I may be able to share the repo if needed.

VS Code version: Code 1.78.2 (b3e4e68a0bc097f0ae7907b217c1119af9e03435, 2023-05-10T15:00:40.428Z) OS version: Darwin arm64 21.6.0 Modes: Sandboxed: No

System Info |Item|Value| |---|---| |CPUs|Apple M1 (8 x 24)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|3, 3, 2| |Memory (System)|8.00GB (0.07GB free)| |Process Argv|--crash-reporter-id 63ed6f6e-71ac-4a4d-ab65-103921cdbbe4| |Screen Reader|yes| |VM|0%|
Process Info ``` CPU % Mem MB PID Process 14 98 89983 code main 0 41 89987 gpu-process 0 16 89991 utility-network-service 0 49 90240 shared-process 0 25 90282 ptyHost 0 0 91050 /bin/ps -ax -o pid=,ppid=,pcpu=,pmem=,command= 0 98 90925 window [2] (partner.add-modal.use.tsx — paygroup.admin) 0 49 90926 extensionHost [2] 0 33 90929 electron-nodejs (/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) --ms-enable-electron-run-as-node --max-old-space-size=3072 /Users/seyaobey/.vscode/extensions/ms-vscode.vscode-typescript-next-5.2.20230517/node_modules/typescript/lib/tsserver.js --serverMode partialSemantic --useInferredProjectPerProjectRoot --disableAutomaticTypingAcquisition --cancellationPipeName /var/folders/fs/mgcn9dds60114gl150cz1fk40000gn/T/vscode-typescript501/35ee43ed7190c8805b9f/tscancellation-72f5be4c10896b14b034.tmp* --logVerbosity verbose --logFile /Users/seyaobey/Library/Application Support/Code/logs/20230526T111328/window2/exthost/vscode.typescript-language-features/tsserver-log-LkxsAG/tsserver.log --traceDirectory /Users/seyaobey/Library/Application Support/Code/logs/20230526T111328/window2/exthost/vscode.typescript-language-features/tsserver-log-eWQr91 --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation --useNodeIpc) 100 483 90930 electron-nodejs (/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) --ms-enable-electron-run-as-node --max-old-space-size=3072 /Users/seyaobey/.vscode/extensions/ms-vscode.vscode-typescript-next-5.2.20230517/node_modules/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName /var/folders/fs/mgcn9dds60114gl150cz1fk40000gn/T/vscode-typescript501/35ee43ed7190c8805b9f/tscancellation-69581a53adbe78be5516.tmp* --logVerbosity verbose --logFile /Users/seyaobey/Library/Application Support/Code/logs/20230526T111328/window2/exthost/vscode.typescript-language-features/tsserver-log-z9Pf7N/tsserver.log --traceDirectory /Users/seyaobey/Library/Application Support/Code/logs/20230526T111328/window2/exthost/vscode.typescript-language-features/tsserver-log-c2GGQh --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation --useNodeIpc) 0 25 90932 electron-nodejs (/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) --ms-enable-electron-run-as-node /Users/seyaobey/.vscode/extensions/ms-vscode.vscode-typescript-next-5.2.20230517/node_modules/typescript/lib/typingsInstaller.js --globalTypingsCacheLocation /Users/seyaobey/Library/Caches/typescript/5.2 --enableTelemetry --logFile /Users/seyaobey/Library/Application Support/Code/logs/20230526T111328/window2/exthost/vscode.typescript-language-features/tsserver-log-z9Pf7N/ti-90930.log --typesMapLocation /Users/seyaobey/.vscode/extensions/ms-vscode.vscode-typescript-next-5.2.20230517/node_modules/typescript/lib/typesMap.json --validateDefaultNpmLocation) 99 467 90931 electron-nodejs (/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) --ms-enable-electron-run-as-node --max-old-space-size=3072 /Users/seyaobey/.vscode/extensions/ms-vscode.vscode-typescript-next-5.2.20230517/node_modules/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --disableAutomaticTypingAcquisition --cancellationPipeName /var/folders/fs/mgcn9dds60114gl150cz1fk40000gn/T/vscode-typescript501/35ee43ed7190c8805b9f/tscancellation-29c648ff41a4b41a27d6.tmp* --logVerbosity verbose --logFile /Users/seyaobey/Library/Application Support/Code/logs/20230526T111328/window2/exthost/vscode.typescript-language-features/tsserver-log-89Lq7D/tsserver.log --traceDirectory /Users/seyaobey/Library/Application Support/Code/logs/20230526T111328/window2/exthost/vscode.typescript-language-features/tsserver-log-kaS1Is --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation --useNodeIpc) 0 33 90950 electron-nodejs (/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) --ms-enable-electron-run-as-node /Users/seyaobey/.vscode/extensions/dbaeumer.vscode-eslint-2.4.0/server/out/eslintServer.js --node-ipc --clientProcessId=90926) 0 33 90927 fileWatcher [2] 0 82 91042 window [4] (Issue Reporter) ```
Workspace Info ``` | Window (partner.add-modal.use.tsx — paygroup.admin) | Folder (paygroup.admin): 417 files | File types: woff2(70) pack(59) js(55) tsx(54) ts(48) json(25) old(3) | DS_Store(3) svg(2) remote(1) | Conf files: package.json(3) tsconfig.json(1); ```
Extensions (2) Extension|Author (truncated)|Version ---|---|--- vscode-eslint|dba|2.4.0 vscode-typescript-next|ms-|5.2.20230517
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 vserr242:30382549 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscod805:30301674 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 cmake_vspar411:30581797 vsaa593cf:30376535 pythonvs932:30410667 cppdebug:30492333 vsclangdf:30486550 c4g48928:30535728 dsvsc012:30540252 pynewext54:30695312 azure-dev_surveyone:30548225 vscccc:30610679 282f8724:30602487 pyind779:30671433 f6dab269:30613381 pythonsymbol12:30671437 2i9eh265:30646982 showlangstatbar:30737416 vsctsb:30748421 pythonms35:30701012 pythonfmttext:30731395 pythoncmv:30739700 fixhidewlkth:30730051 pythongtdpath:30739704 ```
seyaobey-dev commented 1 year ago

I'm observing that in order to get intellisense, auto-suggestion and even error reporting to "some what" work in a file, I must constantly restart the typescript server.

RyanCavanaugh commented 1 year ago

We'd need a concrete repro to be able to investigate further

ustuncem commented 1 year ago

This issue still persists.. I can share a private repo if you want. This only happens in a Next.js 13 project.

JanSmrcka commented 10 months ago

I am facing the same issue, I have one huge .d.ts file with around 12000 lines, without that file it works fine. When file was under 10000 it works relative ok, but now when open new file need to wait for minutes to intellisense, auto-suggestion and even error work. Project is also Next.js 13.

Version: 1.83.1 (Universal) Commit: f1b07bd25dfad64b0167beb15359ae573aecd2cc Date: 2023-10-10T23:46:55.789Z (6 days ago) Electron: 25.8.4 ElectronBuildId: 24154031 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Darwin arm64 23.0.0

I also tryied different machine with fresh OS installation and VS Code - insiders without extensions, but issue persist.

Version: 1.84.0-insider Commit: f1c3b1dcf85e3b6ddb24b7dce0e4b122e8ce6233 Date: 2023-10-17T05:45:00.205Z Electron: 25.8.4 ElectronBuildId: 24154031 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Darwin arm64 22.6.0

MiroslavPetrik commented 8 months ago

Happens to me in next14 with a generated edgedb client which is a huge amount of TS code as well. I've added the generated folder into exclude in my tsconfig, and now it runs.

Edit: It appears the edgedb client is not the issue, as it got stuck again while its ignored. My app is based on https://github.com/MiroslavPetrik/net3-starter the common denominator appears to be the app directory of next.js. I'm on windows 11

MiroslavPetrik commented 8 months ago

I've enabled

  "typescript.tsserver.log": "verbose",

in my vscode settings and isolated the long-duration request:

Info 6535 [16:36:32.180] request:
    {
      "seq": 989,
      "type": "request",
      "command": "encodedSemanticClassifications-full",
      "arguments": {
        "file": "c:\\Users\\miros\\code\\hobik\\src\\app\\(user)\\settings\\addresses\\page.tsx",
        "start": 0,
        "length": 854,
        "format": "2020"
      }
    }
Perf 6536 [16:51:39.176] 989::encodedSemanticClassifications-full: elapsed time (in milliseconds) 906998.3197
Info 6537 [16:51:39.176] response:
    {"seq":0,"type":"response","command":"encodedSemanticClassifications-full","request_seq":989,"success":true,"body":{"spans":[298,11,2057,314,4,2561,334,6,2561,350,7,2561,403,9,2821,428,9,2089,448,3,2056,452,7,2560,460,12,2560,473,5,3072,794,9,2088,805,11,2056],"endOfLineState":0}}

no idea what it means but 15minutes is long response time

what I did on that page, is only to click on a react component in the JSX in order to go to its definition... but it behaves the same for any type information, e.g. when hovering a type or attempt to go into library types etc

related issues https://github.com/microsoft/TypeScript/issues/49053 https://github.com/microsoft/vscode/issues/181953

MiroslavPetrik commented 7 months ago

I've downgraded to ts v. 5.0.3 for now and it allows me to work again. Still the DX is not ideal, some types takes few seconds to resolve. The project besides edgedb client has trpc + zod. All of this is loads of types. I'm experiencing also undeterminism as sometimes the trpc resolves to some err state and I must restar the TS server and all is fine again.

roryscot commented 3 weeks ago

I'm facing this issue currently in VSCode, on several MacBook Pros, both M2 and Intel:

2024-08-15 18:57:48.766 [trace] <semantic> Response received: encodedSemanticClassifications-full (210). Request took 155445 ms. Success: true { "spans": [ 467, 11, 2817, 493, 5, 2560, 500, 4, 2089, 509, 10, 2816, 520, 11, 2056, 543, 7, 2089, 552, 10, 2857, 566, 8, 2816, 575, 12, 1536, 600, 6, 2089, 609, 10, 2816, 620, 21, 2056, 686, 10, 2857, 699, 11, 2816, 737, 4, 2560, 743, 8, 2089, 762, 6, 2088, 769, 6, 2560, 776, 11, 2560, 788, 4, 3072, 801, 6, 2561, 819, 5, 2561, 838, 2, 2561, 842, 4, 2088, 848, 10, 2560, 899, 8, 2088, 908, 6, 2576, 918, 10, 2856, 929, 8, 2088, 949, 6, 2088, 956, 6, 2560, 963, 11, 2560, 976, 4, 2088, 987, 9, 2816, 1009, 10, 2856, 1029, 6, 2088, 1036, 6, 2560, 1043, 11, 2560, 1056, 4, 2088, 1124, 7, 2088, 1160, 4, 2561, 1178, 7, 2561, 1205, 8, 2561, 1240, 5, 2561, 1259, 7, 2561, 1286, 8, 2561, 1321, 12, 2561, 1347, 7, 2561, 1374, 8, 2561, 1409, 6, 2561, 1429, 7, 2561, 1456, 8, 2561 ], "endOfLineState": 0 }

encodedSemanticClassifications-full took almost a minute and an half. I'm not sure what the root cause is, but it seems to be related to a large type generated by @aws/amplify as a schema.

You can try reproducing by deleting a dependency and generating the help menu here https://github.com/humanifest/femmes-vitale/blob/a365931584094827318caa27684a273f691d0b2a/src/components/UserProfile/UserProfile.tsx#L28C40-L28C50

RyanCavanaugh commented 3 weeks ago

@roryscot please file a new issue with complete and minimal repro steps