microsoft / TypeScript

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

TS Server fatal error: Cannot read properties of undefined (reading 'charCount') #56413

Closed zirondi closed 1 month ago

zirondi commented 10 months ago

Type: Bug

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

TypeScript Version: 5.3.1-rc

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: syntax

TypeError: Cannot read properties of undefined (reading 'charCount')
    at _LineNode.walk (c:\Users\ziron\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:186096:30)
    at _LineIndex.edit (c:\Users\ziron\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:185995:17)
    at _ScriptVersionCache._getSnapshot (c:\Users\ziron\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:185801:31)
    at _ScriptVersionCache.lineOffsetToPosition (c:\Users\ziron\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:185820:17)
    at TextStorage.lineOffsetToPosition (c:\Users\ziron\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:175907:22)
    at ScriptInfo.lineOffsetToPosition (c:\Users\ziron\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:176228:29)
    at c:\Users\ziron\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:182791:41
    at mapDefinedIterator (c:\Users\ziron\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:2678:19)
    at mapDefinedIterator.next (<anonymous>)
    at _ProjectService.applyChangesToFile (c:\Users\ziron\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:181597:16)
    at _ProjectService.applyChangesInOpenFiles (c:\Users\ziron\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:181568:14)
    at updateOpen (c:\Users\ziron\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:182780:29)
    at c:\Users\ziron\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:185382:69
    at IpcIOSession.executeWithRequestId (c:\Users\ziron\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:185374:14)
    at IpcIOSession.executeCommand (c:\Users\ziron\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:185382:29)
    at IpcIOSession.onMessage (c:\Users\ziron\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:185424:51)
    at process.<anonymous> (c:\Users\ziron\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:187006:14)
    at process.emit (node:events:513:28)
    at emit (node:internal/child_process:937:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)

VS Code version: Code - Insiders 1.85.0-insider (345c8d0927402d41f42402411d856eeec4013e5e, 2023-11-13T05:39:23.476Z) OS version: Windows_NT x64 10.0.22631 Modes:

System Info |Item|Value| |---|---| |CPUs|AMD Ryzen 7 3750H with Radeon Vega Mobile Gfx (8 x 2296)| |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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|21.94GB (10.19GB free)| |Process Argv|. --crash-reporter-id 09db47df-2084-4e20-9ef0-2c1fbe5e9bfe| |Screen Reader|no| |VM|0%|
Extensions (26) Extension|Author (truncated)|Version ---|---|--- rc-beautify|Ato|1.2.0 vscode-markdownlint|Dav|0.52.0 conda-wingman|DJS|0.2.1 gitlens|eam|2023.11.1404 vscode-html-css|ecm|1.13.1 code-runner|for|0.12.1 copilot|Git|1.136.0 copilot-chat|Git|0.11.2023111401 conda-cheatsheet|joj|1.2.8 vscode-docker|ms-|1.28.0 python|ms-|2023.21.13181010 vscode-pylance|ms-|2023.11.12 jupyter|ms-|2023.11.1003202024 jupyter-keymap|ms-|1.1.2 jupyter-renderers|ms-|1.0.17 vscode-jupyter-cell-tags|ms-|0.1.8 vscode-jupyter-slideshow|ms-|0.1.5 remote-containers|ms-|0.324.0 remote-wsl|ms-|0.81.8 powershell|ms-|2023.8.0 autodocstring|njp|0.6.1 fabric8-analytics|red|0.7.3 markdown-preview-enhanced|shd|0.8.10 pdf|tom|1.2.2 vscode-beautify|vsc|1.5.12 vscode-gradle|vsc|3.13.4 (2 theme extensions excluded)
A/B Experiments ``` vsliv695:30137379 vsins829:30139715 vsliv368:30146709 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 pythontb:30258533 vsc_aacf:30263846 pythonptprofiler:30281269 vsdfh931:30280409 vshan820:30294714 vscod805cf:30301675 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 pythonvs932:30404738 py29gd2263:30784851 vsclangdf:30492506 c4g48928:30535728 dsvsc012:30540252 pynewext54:30618038 vscrp:30624060 2i9eh265:30646982 showlangstatbar:30737417 pythonfmttext:30716741 fixshowwlkth:30771523 showindicator:30805243 pythongtdpath:30726887 i26e3531:30792625 welcomedialog:30812478 pythonnosmt12:30779711 pythonidxpt:30768918 pythonnoceb:30776497 dsvsc013:30777762 dsvsc014:30777825 pythonmpsinfo:30859869 dsvsc015:30821418 pythontestfixt:30866404 pythonregdiag2:30871582 pyreplss1:30879911 pythonmypyd1:30859725 pythoncet0:30859736 pythontbext0:30879054 accentitlementst:30870582 dsvsc016:30879898 dsvsc017:30880771 dsvsc018:30880772 aa_t_chat:30882232 ```
RyanCavanaugh commented 10 months ago

Duplicate #44492 and others. We need a way to reproduce this

zirondi commented 10 months ago

I instinctively hit the report button without checking, sorry. But besides the use of Copilot and large .js files, I wasn't really doing anything out of the ordinary.