microsoft / TypeScript

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

TS Server fatal error: Cannot read property 'sourceFile' of undefined #45129

Closed karimkawambwa closed 1 month ago

karimkawambwa commented 3 years ago

Issue Type: Bug

❗️❗️❗️ Please fill in the sections below to help us diagnose the issue ❗️❗️❗️

TypeScript Version: 4.3.5

Steps to reproduce crash 1. 2. 3.

TS Server Log ❗️Server logging disabled. To help us fix crashes like this, please enable logging by setting:

"typescript.tsserver.log": "verbose"

After enabling this setting, future crash reports will include the server log.

TS Server Error Stack Server: semantic

TypeError: Cannot read property 'sourceFile' of undefined
    at isDocumentRegistryEntry (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:126119:24)
    at getDocumentRegistryEntry (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:126173:25)
    at Object.releaseDocumentWithKey (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:126250:25)
    at Object.onReleaseOldSourceFile (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:153243:34)
    at Object.createProgram (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:109460:26)
    at synchronizeHostData (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:153176:26)
    at Proxy.getProgram (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:153308:13)
    at InferredProject.Project.updateGraphWorker (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:158256:53)
    at InferredProject.Project.updateGraph (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:158184:42)
    at updateProjectIfDirty (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:159634:45)
    at Array.forEach (<anonymous>)
    at ProjectService.assignProjectToOpenedScriptInfo (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:161952:41)
    at /Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:162238:97
    at Object.flatMap (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:515:25)
    at ProjectService.applyChangesInOpenFiles (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:162238:41)
    at Session.handlers.ts.Map.ts.getEntries._a.<computed> (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:163293:46)
    at /Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:165210:88
    at IOSession.Session.executeWithRequestId (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:165201:28)
    at IOSession.Session.executeCommand (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:165210:33)
    at IOSession.Session.onMessage (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:165236:35)
    at Interface.<anonymous> (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:167833:31)
    at Interface.emit (events.js:315:20)
    at Interface._onLine (readline.js:337:10)
    at Interface._normalWrite (readline.js:482:12)
    at Socket.ondata (readline.js:194:10)
    at Socket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)

VS Code version: Code - Insiders 1.58.0-insider (99c968565a27846c330d3498e178184bcb9dd963, 2021-07-06T09:59:53.949Z) OS version: Darwin arm64 20.4.0 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|Apple M1 (8 x 24)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled| |Load (avg)|5, 4, 3| |Memory (System)|8.00GB (0.18GB free)| |Process Argv|--crash-reporter-id 25148607-8b7f-4f06-a4e8-f28237eb8a8a| |Screen Reader|no| |VM|0%|
Extensions (18) Extension|Author (truncated)|Version ---|---|--- vscode-eslint|dba|2.1.23 gitlens|eam|11.6.0 prettier-vscode|esb|8.0.1 go|gol|0.26.0 terraform|has|2.13.2 solidity|Jua|0.0.124 vscode-phpfmt|kok|1.0.30 kretes|kre|0.0.1 ligo-vscode|lig|0.4.2 vscode-docker|ms-|1.15.0 python|ms-|2021.6.944021595 vscode-pylance|ms-|2021.7.4 jupyter|ms-|2021.8.1046824664 remote-containers|ms-|0.187.1 prisma-insider|Pri|28.0.2 prettier-now|rem|1.4.9 vs-code-prettier-eslint|rve|3.0.4 graphviz-interactive-preview|tin|0.0.11
A/B Experiments ``` vsliv695:30137379 vsins829:30139715 vsliv368:30146709 vsreu685:30147344 python383:30185418 pythonvspyt602:30291494 vspor879:30202332 vspor708:30202333 vspor363:30204092 pythonvspyt639:30291487 pythontb:30258533 vsc_aacf:30263846 pythonvspyt551cf:30291413 vspre833:30321513 pythonptprofiler:30281269 vsdfh931cf:30280410 vshan820:30294714 pythondataviewer:30285072 vscus158:30321503 pythonvsuse255:30319630 vscod805cf:30301675 pythonvspyt200:30323110 vscextlangct:30310089 vsccppwt:30312692 pythonvssor306:30340298 bridge0708:30335490 ```
mjbvz commented 3 years ago

Please try collecting the TS Server log from the crashed instance:

  1. Set "typescript.tsserver.log": "verbose"
  2. Restart VS Code and reproduce the problem
  3. Open the TypeScript section of the output panel
  4. At the very top, find the first line that prints to path to the semantic error log file. It should look something like:

    [Info  - 19:54:59.247] <semantic> Log file: /Users/matb/Library/Application Support/Code - Insiders/logs/20200213T104930/exthost55/vscode.typescript-language-features/tsserver-log-ZT2zau/tsserver.log

    That file contains the typescript logs that should help us track down what is going wrong

    ⚠️Warning: The TypeScript log may include information from your workspace, including file paths and source code. If you have any concerns about posting this publicly on Github, just let me know and we can arrange something else. On our side, we only use these logs to investigate issues like this

andrewbranch commented 3 years ago

This is the only report with this stack we’ve seen—@karimkawambwa it would be super helpful if you could provide some additional info 🙂

karimkawambwa commented 3 years ago

@andrewbranch @mjbvz

I was not able to reproduce the error, if this comes back, I will be sure to share details here.