Skip to content

TS Server fatal error: Cannot read property 'lastIndexOf' of undefined #45898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jslq opened this issue Sep 8, 2021 · 2 comments
Closed

TS Server fatal error: Cannot read property 'lastIndexOf' of undefined #45898

jslq opened this issue Sep 8, 2021 · 2 comments
Assignees

Comments

@jslq
Copy link

jslq commented Sep 8, 2021

Issue Type: Bug

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

TypeScript Version: 4.4.2

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 'lastIndexOf' of undefined
    at Object.startsWith (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:2064:20)
    at isNodeModulesOrScopedPackageDirectory (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:19715:65)
    at guessDirectorySymlink (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:19703:17)
    at processResolution (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:19692:22)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:19683:162
    at Map.forEach (<anonymous>)
    at Object.setSymlinksFromResolutions (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:19683:123)
    at ConfiguredProject.Project.getSymlinkCache (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:161077:35)
    at Object.getSymlinkCache (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:114006:29)
    at Object.host.compilerHost.realpath (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:114071:36)
    at realPath (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:41680:42)
    at Object.resolveTypeReferenceDirective (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:41044:74)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:162436:112
    at Object.map (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:455:29)
    at Function.AutoImportProviderProject.getRootFileNames (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:162436:42)
    at Function.AutoImportProviderProject.create (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:162468:38)
    at ConfiguredProject.Project.getPackageJsonAutoImportProvider (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:162270:77)
    at ConfiguredProject.Project.updateGraph (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:161693:26)
    at ConfiguredProject.updateGraph (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:162637:63)
    at ProjectService.createLoadAndUpdateConfiguredProject (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:164361:25)
    at ProjectService.assignProjectToOpenedScriptInfo (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:165444:44)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:165784:97
    at Object.flatMap (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:519:25)
    at ProjectService.applyChangesInOpenFiles (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:165784:41)
    at Session.handlers.ts.Map.ts.getEntries._a.<computed> (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:166942:46)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:168873:88
    at IOSession.Session.executeWithRequestId (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:168864:28)
    at IOSession.Session.executeCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:168873:33)
    at IOSession.Session.onMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:168899:35)
    at Interface.<anonymous> (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:171504: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 1.60.0 (e7d7e9a9348e6a8cc8c03f877d39cb72e5dfb1ff, 2021-09-01T10:54:53.442Z)
OS version: Darwin x64 20.5.0
Restricted Mode: No

System Info
Item Value
CPUs Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz (12 x 2600)
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, 8, 7
Memory (System) 32.00GB (7.66GB free)
Process Argv . --crash-reporter-id 442ab1e7-9ea9-42ca-a65b-c5a52b173cf3
Screen Reader no
VM 0%
Extensions (52)
Extension Author (truncated) Version
vscode-nginx-conf ahm 0.1.3
iconify ant 0.1.1
god bas 0.0.104
toml be5 0.5.1
better-toml bun 0.3.2
language-prometheus caa 0.1.2
vscode-sql-beautify cla 0.2.7
vscode-dash dee 2.4.0
githistory don 0.6.18
gitlens eam 11.6.0
EditorConfig Edi 0.16.4
vscode-npm-script eg2 0.3.22
prettier-vscode esb 8.1.0
code-runner for 0.11.5
vscode-yarn gam 2.0.0
go gol 0.27.2
todo-tree Gru 0.0.214
headwind hey 1.7.0
vue-snippets hol 1.0.4
beautify Hoo 1.5.0
kubernetes-snippets ipe 0.1.9
todo iza 0.1.0
gitlab-ci-templates jgs 0.3.0
volar joh 0.27.16
k8s kub 0.0.1
i18n-ally lok 2.8.0
vscode-istio-snippets lor 0.1.0
dotenv mik 1.0.1
vscode-less mrm 0.6.3
vscode-docker ms- 1.16.1
vscode-language-pack-zh-hans MS- 1.60.3
vscode-kubernetes-tools ms- 1.3.3
python ms- 2021.9.1191016588
jupyter ms- 2021.8.2031190714
jupyter-keymap ms- 1.0.0
remote-containers ms- 0.194.0
vsliveshare ms- 1.0.4761
vsliveshare-audio ms- 0.1.91
vsliveshare-pack ms- 0.4.0
debugger-for-chrome msj 4.13.0
minapp-vscode qiu 2.3.4
nginx-formatter ray 0.0.13
vscode-yaml red 0.22.0
vscode-stylelint sty 0.86.0
lua sum 2.3.7
hammerspoon-snippets vir 0.0.5
windicss-intellisense voo 0.21.4
gitblame wad 8.1.0
vscode-nginx wil 0.7.2
vscode-import-cost wix 2.15.0
plsql-language xyz 1.8.2
file-size zh9 1.0.0
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
pythonvspyt602:30300191
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyt639:30300192
pythontb:30283811
pythonvspyt551:30345470
pythonptprofiler:30281270
vsdfh931cf:30280410
vshan820:30294714
vstes263:30335439
pythondataviewer:30285071
pythonvsuse255:30340121
vscod805cf:30301675
pythonvspyt200:30340761
vscextlang:30333561
binariesv615:30325510
pythonvssor306:30344512
bridge0708:30335490
pygetstartedt2:30360495
bridge0723:30353136
pythonf5test824cf:30361778
vsdyn321cf:30356811
pythonvspyt187:30362782
pydsgst2:30361792
vscus224:30358039
vssid140cf:30362081

@jedzej
Copy link

jedzej commented Sep 8, 2021

I am experiencing the same problem

It turned out that I had broken dependencies in my project. After manually removing node_modules and installing the dependencies back the problem disappeared.

Anyway, the error description and call stack dump wasn't very helpful with finding this workaround.

@mjbvz mjbvz transferred this issue from microsoft/vscode Sep 15, 2021
@mjbvz
Copy link
Contributor

mjbvz commented Sep 15, 2021

Duplicate of #44953

@mjbvz mjbvz marked this as a duplicate of #44953 Sep 15, 2021
@mjbvz mjbvz closed this as completed Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants