microsoft / TypeScript

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

Typescript crashes in VS Code insiders latest build with all extensions disabled and TypeScript Nightly extension #52353

Open bennyk8y opened 1 year ago

bennyk8y commented 1 year ago

Hi, in our company we are working in relatively big TS monorepo. For all our developers TS crashes few times a day. My setup:

  1. Visual Studio Code - Insiders - 1.75.0
  2. JavaScript and TypeScript Nightly extension - latest
  3. All extensions are disabled.

Another thing that we've tried is excluding from File Watcher node_modules/** and node_modules but i see its still being watched under, but i guess its a different thing.

Bug Report

🔎 Search Terms

typescript crash, typescript plugin loading infinitely

🕗 Version & Regression Information

Version: 1.75.0-insider
Commit: 243854703b7fa371abb752ec0df7817a615a308b
Date: 2023-01-13T08:04:47.712Z (1 wk ago)
Electron: 19.1.9
Chromium: 102.0.5005.194
Node.js: 16.14.2
V8: 10.2.154.23-electron.0
OS: Darwin arm64 21.3.0
Sandboxed: Yes 

The indications for this crash are

  1. Typescript icon loading infinitely
  2. Hovering on any code have a ("loading...") indication
  3. All Typescript features aren't working
bennyk8y commented 1 year ago

setting this in tsconfig.json

"exclude": ["**/node_modules", "node_modules"]

in every package in the monorepo should help?

DanielRosenwasser commented 1 year ago

Would you be able to provide us with a TSServer log from VS Code?

To do this, you'd need to:

  1. Open up your command palette and either
    • open your global settings by entering Preferences: Open User Settings
    • open your local project by entering Preferences: Open Workspace Settings
  2. Set the option "typescript.tsserver.log": "verbose",
  3. Restart VS Code and reproduce the problem
  4. In VS Code, run the TypeScript: Open TS Server log command
  5. This should open the tsserver.log file.

âš  Warning: A TSServer log may include information from your workspace, including file paths and source code. If you have any concerns about posting this publicly on GitHub, let us know and you can share the details privately.

bennyk8y commented 1 year ago

@DanielRosenwasser Hi! I have it. Can i share it privately?

DanielRosenwasser commented 1 year ago

Sure, email Myfirstname dot Mylastname at microsoft dot com

(capitalization unfortunately matters)

DanielRosenwasser commented 1 year ago

Just to clarify, this is more of a suspiciously long-running thing/a startup hang - it's not causing an actual crash, right?

bennyk8y commented 1 year ago

Yes, VSCode itself is not crashing, just TS features stop working after this happens, sometimes an error message pops with the message

The JS/TS language service crashed
bennyk8y commented 1 year ago

Just to clarify, all our development team that works on that repo (the main monorepo of the company) suffers from it, TS crashes few times a day. Really not sure how can help VSCode understand not to watch node_modules, which i suspect affects the performance and maybe this somehow related to TS crashes. But maybe the issue is not related to FileWatcher...

bennyk8y commented 1 year ago

@DanielRosenwasser did you get the email?

sheetalkamat commented 5 months ago

@bennyk8y can you please try with latest vscode and nightly and see if this still repros and if yes please share the verbose log and way to repro this to investigate this. Thanks

tomitrescak commented 2 months ago

Hi, I am using the latest VSCODE and typescript constantyl crashes in my monorepo. It works flawlesly with other non monorepo projects.

I followed your instructions, but the TS Log even after few minutes is huge. I scanned it and this is the error that keep repeating:

Err 15216 [14:58:30.541] Exception on executing command delayed processing of request 1542:

    Cannot read properties of undefined (reading 'updateFromProject')

    TypeError: Cannot read properties of undefined (reading 'updateFromProject')
        at synchronizeHostData (/Users/30031005/Github/skillpies/node_modules/.pnpm/typescript@5.5.1-rc/node_modules/typescript/lib/typescript.js:148905:14)
        at Object.getProgram (/Users/30031005/Github/skillpies/node_modules/.pnpm/typescript@5.5.1-rc/node_modules/typescript/lib/typescript.js:149084:5)
        at getSource (/Users/30031005/Github/skillpies/node_modules/.pnpm/next@15.0.0-rc.0_@babel+core@7.24.7_babel-plugin-macros@3.1.0_react-dom@19.0.0-rc-c21bcd627b-_czrxpi2kri5ztqn2ft65hk2xum/node_modules/next/dist/server/typescript/utils.js:98:69)
        at proxy.getSemanticDiagnostics (/Users/30031005/Github/skillpies/node_modules/.pnpm/next@15.0.0-rc.0_@babel+core@7.24.7_babel-plugin-macros@3.1.0_react-dom@19.0.0-rc-c21bcd627b-_czrxpi2kri5ztqn2ft65hk2xum/node_modules/next/dist/server/typescript/index.js:103:49)
        at TemplateLanguageServiceProxy.adaptDiagnosticsCall (/Users/30031005/.vscode/extensions/styled-components.vscode-styled-components-1.7.8/node_modules/typescript-template-language-service-decorator/lib/template-language-service-decorator.js:288:33)
        at Proxy.<anonymous> (/Users/30031005/.vscode/extensions/styled-components.vscode-styled-components-1.7.8/node_modules/typescript-template-language-service-decorator/lib/template-language-service-decorator.js:54:25)
        at IpcIOSession.semanticCheck (/Users/30031005/Github/skillpies/node_modules/.pnpm/typescript@5.5.1-rc/node_modules/typescript/lib/typescript.js:189731:125)
        at /Users/30031005/Github/skillpies/node_modules/.pnpm/typescript@5.5.1-rc/node_modules/typescript/lib/typescript.js:189792:14
        at MultistepOperation.executeAction (/Users/30031005/Github/skillpies/node_modules/.pnpm/typescript@5.5.1-rc/node_modules/typescript/lib/typescript.js:188448:9)
        at /Users/30031005/Github/skillpies/node_modules/.pnpm/typescript@5.5.1-rc/node_modules/typescript/lib/typescript.js:188421:71
        at IpcIOSession.executeWithRequestId (/Users/30031005/Github/skillpies/node_modules/.pnpm/typescript@5.5.1-rc/node_modules/typescript/lib/typescript.js:191498:14)
        at Object.executeWithRequestId (/Users/30031005/Github/skillpies/node_modules/.pnpm/typescript@5.5.1-rc/node_modules/typescript/lib/typescript.js:189477:57)
        at Immediate._onImmediate (/Users/30031005/Github/skillpies/node_modules/.pnpm/typescript@5.5.1-rc/node_modules/typescript/lib/typescript.js:188421:28)
        at process.processImmediate (node:internal/timers:480:21)

I can give you priveate access to my repo if needed. I would love to see where the error might originate ?

sheetalkamat commented 2 months ago

it seems like some plugin you have thats not handling things correctly as i dont see why you should run into this as its guarded correctly. https://github.com/microsoft/TypeScript/blob/3163fe7e3898c1f48cd9bc097b96e3426cd2a453/src/services/services.ts#L1683