microsoft / TypeScript

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

IntelliSense not functioning in large project sometimes #56155

Open Zzzen opened 1 year ago

Zzzen commented 1 year ago

🔎 Search Terms

language server loading updateGraphWorker IntelliSense not working

🕗 Version & Regression Information

⏯ Playground Link

No response

💻 Code

No response

🙁 Actual behavior

While working on a large TypeScript project, we have encountered a decline in the developer experience as the project continues to grow. One particular issue we have experienced is that IntelliSense consistently gets stuck without any apparent reason. To investigate this further, I attempted to enable the debug mode of the TypeScript server and discovered that it hangs at the updateGraphWorker stage.

Info 17820[15:27:03.183] -----------------------------------------------
Info 17820[15:27:03.195] event:
    {"seq":0,"type":"event","event":"projectLoadingFinish","body":{"projectName":"/path/to/some/json"}}
Info 17820[15:27:03.202] event:
    {"seq":0,"type":"event","event":"telemetry","body":{"telemetryEventName":"projectInfo","payload":{"projectId":"xxxx","fileStats":{"js":0,"jsSize":0,"jsx":0,"jsxSize":0,"ts":1744,"tsSize":2689631,"tsx":108,"tsxSize":347124,"dts":3944,"dtsSize":8979876,"deferred":0,"deferredSize":0},"compilerOptions":{"experimentalDecorators":true,"emitDecoratorMetadata":true,"strict":true,"allowUnreachableCode":false,"outDir":"","target":"es2022","declaration":true,"module":"esnext","esModuleInterop":true,"moduleResolution":"node10","verbatimModuleSyntax":true,"useDefineForClassFields":false,"sourceMap":true,"skipLibCheck":true,"plugins":[""],"jsx":"preserve","baseUrl":"","paths":"","composite":true,"rootDir":"","declarationDir":"","resolveJsonModule":true},"typeAcquisition":{"enable":false,"include":false,"exclude":false},"extends":true,"files":false,"include":true,"exclude":false,"compileOnSave":false,"configFileName":"tsconfig.json","projectType":"configured","languageServiceEnabled":true,"version":"5.2.2"}}}
Info 17820[15:27:03.203] Creating configuration project /path/to/some/json
Info 17820[15:27:03.203] event:
    {"seq":0,"type":"event","event":"projectLoadingStart","body":{"projectName":"/path/to/some/json"}}
Info 17820[15:27:03.204] FileWatcher:: Added:: WatchInfo: /path/to/some/ts 500 undefined WatchType: Closed Script info
Info 17821[15:27:03.205] FileWatcher:: Added:: WatchInfo: /path/to/some/ts 500 undefined WatchType: Closed Script info
Info 17821[15:27:03.206] FileWatcher:: Added:: WatchInfo: /path/to/some/ts 500 undefined WatchType: Closed Script info
Info 17821[15:27:03.206] FileWatcher:: Added:: WatchInfo: /path/to/some/ts 500 undefined WatchType: Closed Script info
Info 17821[15:27:03.207] FileWatcher:: Added:: WatchInfo: /path/to/some/ts 500 undefined WatchType: Closed Script info
Info 17821[15:27:03.207] FileWatcher:: Added:: WatchInfo: /path/to/some/ts 500 undefined WatchType: Closed Script info
Info 17821[15:27:03.208] FileWatcher:: Added:: WatchInfo: /path/to/some/ts 500 undefined WatchType: Closed Script info
Info 17821[15:27:03.223] Starting updateGraphWorker: Project: /path/to/some/json
Info 17821[15:27:03.311] DirectoryWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: Failed Lookup Locations
Info 17821[15:27:03.311] Elapsed:: 0.012974977493286133ms DirectoryWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: Failed Lookup Locations
Info 17821[15:27:03.311] DirectoryWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: Failed Lookup Locations
Info 17822[15:27:03.311] Elapsed:: 0.0058460235595703125ms DirectoryWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: Failed Lookup Locations
Info 17822[15:27:03.311] DirectoryWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: Failed Lookup Locations
Info 17822[15:27:03.311] Elapsed:: 0.0055010318756103516ms DirectoryWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: Failed Lookup Locations
Info 17822[15:27:03.311] DirectoryWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: Failed Lookup Locations
Info 17822[15:27:03.311] Elapsed:: 0.011311054229736328ms DirectoryWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: Failed Lookup Locations
Info 17822[15:27:03.311] DirectoryWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: Failed Lookup Locations
Info 17822[15:27:03.311] Elapsed:: 0.004781007766723633ms DirectoryWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: Failed Lookup Locations
Info 17822[15:27:03.312] DirectoryWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: Failed Lookup Locations
Info 17822[15:27:03.312] Elapsed:: 0.008038997650146484ms DirectoryWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: Failed Lookup Locations
Info 17822[15:27:03.312] FileWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: File location affecting resolution
Info 17823[15:27:03.316] DirectoryWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: Failed Lookup Locations
Info 17823[15:27:03.316] Elapsed:: 0.010488033294677734ms DirectoryWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: Failed Lookup Locations
Info 17823[15:27:03.317] FileWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: File location affecting resolution
Info 17823[15:27:03.319] FileWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: File location affecting resolution
Info 17823[15:27:03.322] FileWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: File location affecting resolution
Info 17823[15:27:03.824] DirectoryWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: Failed Lookup Locations
Info 17823[15:27:03.824] Elapsed:: 0.0059119462966918945ms DirectoryWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: Failed Lookup Locations
Info 17823[15:27:03.915] DirectoryWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: Failed Lookup Locations
Info 17823[15:27:03.915] Elapsed:: 0.008075952529907227ms DirectoryWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: Failed Lookup Locations
Info 17823[15:27:04.015] FileWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: File location affecting resolution
Info 17824[15:27:04.532] FileWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: File location affecting resolution
Info 17824[15:27:05.703] FileWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: File location affecting resolution
Info 17824[15:27:05.748] FileWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: File location affecting resolution
Info 17824[15:27:07.812] FileWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: File location affecting resolution
Info 17824[15:27:07.843] FileWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: File location affecting resolution
Info 17824[15:27:08.790] FileWatcher:: Added:: WatchInfo: /path/to/some/json WatchType: File location affecting resolution

# log stops here

🙂 Expected behavior

In our large project, we expect IntelliSense to work smoothly since the project can be type checked within approximately 2 minutes.

Additional information about the issue

No response

RyanCavanaugh commented 1 year ago

We'll need some way to reproduce this

en-yash commented 1 year ago

@Zzzen we are facing a similar issue with intellisense performance in our monorepo. Is your repo using tsc using project references? Keen to receive some support from the typescript team on this issue

Zzzen commented 1 year ago

Yes, we are using project references.

Zzzen commented 11 months ago

I found a solution that worked for me. By installing the JavaScript and TypeScript Nightly extension from the Visual Studio Marketplace (JavaScript and TypeScript Nightly - Visual Studio Marketplace) and setting the typescript.tsserver.nodePath configuration option in Visual Studio Code to the latest version of Node.js, I was able to resolve the problem.