Skip to content
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

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

Closed
JakeTompkins opened this issue Jul 8, 2021 · 7 comments · Fixed by #46105
Closed

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

JakeTompkins opened this issue Jul 8, 2021 · 7 comments · Fixed by #46105
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@JakeTompkins
Copy link

Issue Type: Bug

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

TypeScript Version: 4.4.0-dev.20210707

Steps to reproduce crash

  1. I just opended the project

TS Server Log
❗️ Please review and upload this log file to help us diagnose this crash:
/Users/jake/Library/Application Support/Code/logs/20210627T002751/exthost17/vscode.typescript-language-features/tsserver-log-jDF14S/tsserver.log
The log file may contain personal data, including full paths and source code from your workspace. You can scrub the log file to remove paths or other personal information.

TS Server Error Stack
Server: semantic

TypeError: Cannot read property 'lastIndexOf' of undefined
    at Object.startsWith (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:2064:20)
    at isNodeModulesOrScopedPackageDirectory (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:19667:65)
    at guessDirectorySymlink (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:19655:17)
    at processResolution (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:19644:22)
    at /Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:19635:162
    at Map.forEach (<anonymous>)
    at Object.setSymlinksFromResolutions (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:19635:123)
    at ConfiguredProject.Project.getSymlinkCache (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:160332:35)
    at Object.getSymlinkCache (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:113527:29)
    at Object.host.compilerHost.realpath (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:113592:36)
    at realPath (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:41457:42)
    at Object.resolveTypeReferenceDirective (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:40825:74)
    at /Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:161687:112
    at Object.map (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:455:29)
    at Function.AutoImportProviderProject.getRootFileNames (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:161687:42)
    at Function.AutoImportProviderProject.create (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:161720:38)
    at ConfiguredProject.Project.getPackageJsonAutoImportProvider (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:161525:77)
    at ConfiguredProject.Project.updateGraph (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:160948:26)
    at ConfiguredProject.updateGraph (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:161889:63)
    at ProjectService.createLoadAndUpdateConfiguredProject (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:163613:25)
    at ProjectService.assignProjectToOpenedScriptInfo (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:164694:44)
    at /Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:165034:97
    at Object.flatMap (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:519:25)
    at ProjectService.applyChangesInOpenFiles (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:165034:41)
    at Session.handlers.ts.Map.ts.getEntries._a.<computed> (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:166194:46)
    at /Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:168121:88
    at IOSession.Session.executeWithRequestId (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:168112:28)
    at IOSession.Session.executeCommand (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:168121:33)
    at IOSession.Session.onMessage (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:168147:35)
    at Interface.<anonymous> (/Users/jake/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-4.4.20210707/node_modules/typescript/lib/tsserver.js:170746: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.57.1 (507ce72a4466fbb27b715c3722558bb15afa9f48, 2021-06-17T13:28:32.912Z)
OS version: Darwin x64 20.5.0
Restricted Mode: No

System Info
Item Value
CPUs Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz (8 x 2000)
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) 6, 5, 4
Memory (System) 16.00GB (0.48GB free)
Process Argv . --crash-reporter-id 18502848-7f0c-420a-ac31-a1e1385e09ba
Screen Reader no
VM 0%
Extensions (87)
Extension Author (truncated) Version
better-comments aar 2.1.0
vscode-javascript-repl ach 0.7.2
Bookmarks ale 13.1.0
jest-snippets and 1.8.0
vscode-apollo apo 1.19.3
emojisense bie 0.8.0
markdown-checkbox bie 0.1.3
vscode-tailwindcss bra 0.6.13
pgformatter bra 1.17.0
multi-cursor-case-preserve Car 1.0.5
npm-intellisense chr 1.3.1
path-intellisense chr 2.3.0
codeswing cod 0.0.19
gitignore cod 0.7.0
bracket-pair-colorizer-2 Coe 0.2.1
vscode-eslint dba 2.1.23
es7-react-js-snippets dsz 3.1.1
docthis-customize-tags dwe 0.4.5
gitlens eam 11.5.1
vscode-npm-script eg2 0.3.22
vscode-great-icons emm 2.1.79
moxer-icons Equ 5.8.0
vsc-material-theme-icons equ 1.2.2
prettier-vscode esb 8.0.1
code-runner for 0.11.4
vscode-pull-request-github Git 0.27.1
ruby gro 0.1.0
todo-tree Gru 0.0.213
ruby-linter hoo 1.0.0
rest-client hum 0.24.5
output-colorizer IBM 0.1.2
monkey-patch ioc 0.1.15
vscode-essentials jab 1.5.0
search-editor-apply-changes jak 0.1.1
vscode-edit-csv jan 0.6.0
rainbow-end jdu 0.7.8
vscode-peacock joh 3.9.1
sublime-babel-vscode jos 0.2.10
chat kar 0.35.0
sequelize-vscode-association-snippet lou 0.0.2
vscode-language-babel mgm 0.0.31
dotenv mik 1.0.1
ruby-rubocop mis 0.8.5
HTMLHint mka 0.10.0
prettify-json moh 0.0.3
vscode-postgresql ms- 0.3.0
python ms- 2021.6.944021595
vscode-pylance ms- 2021.7.2
jupyter ms- 2021.6.999662501
remote-containers ms- 0.183.0
remote-ssh ms- 0.65.7
remote-ssh-edit ms- 0.65.7
remote-wsl ms- 0.56.5
vscode-remote-extensionpack ms- 0.21.0
cpptools ms- 1.4.1
js-debug-nightly ms- 2021.6.1117
typescript-javascript-grammar ms- 0.0.55
vscode-typescript-next ms- 4.4.20210707
vsliveshare ms- 1.0.4531
vsliveshare-audio ms- 0.1.91
debugger-for-chrome msj 4.12.12
color-highlight nau 2.3.0
vscode-javascript-comment Nic 0.0.7
leaper Onl 0.6.0
material-icon-theme PKi 4.8.0
polacode pnp 0.3.4
subtle-brackets raf 3.0.0
vscode-commons red 0.0.6
vscode-xml red 0.17.0
vscode-yaml red 0.20.0
LiveServer rit 5.6.1
rust rus 0.7.8
partial-diff ryu 1.4.3
vscode-sql-beautify sen 0.0.4
trailing-spaces sha 0.3.1
vscode-smoothtype spi 1.2.0
rewrap stk 1.14.0
hyper-javascript-snippets t7y 3.2.1
vscode-status-bar-format-toggle tom 2.0.0
lodash-snippets tom 1.0.0
vscodeintellicode Vis 1.2.14
codetour vsl 0.0.56
gistfs vsl 0.3.0
vscode-ruby win 0.28.0
JavaScriptSnippets xab 1.8.0
vscode-surround yat 1.1.2
markdown-all-in-one yzh 3.4.0

(17 theme extensions excluded)

A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
pythonvspyt602:30300191
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyt639:30300192
pythontb:30283811
pythonvspyt551:30311712
vspre833:30321513
pythonptprofiler:30281270
vshan820:30294714
pythondataviewer:30285071
vscus158:30321503
pythonvsuse255:30323308
vscorehov:30309549
vscod805:30301674
pythonvspyt200:30331937
vscextlangct:30333562
binariesv615:30325510

@mjbvz mjbvz transferred this issue from microsoft/vscode Jul 8, 2021
@mjbvz mjbvz removed their assignment Jul 8, 2021
@mjbvz
Copy link
Contributor

mjbvz commented Jul 8, 2021

Please follow the steps in the issue to provide additional information, such as the server log

@amcasey
Copy link
Member

amcasey commented Jul 8, 2021

I believe MacOS uses a case-insensitive file system by default, so it would have hit the same issue as Windows , but that also means that the same mitigation should apply (with the caveat that all bets are off if your project spans both case-sensitive and case-insensitive file systems).

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Jul 13, 2021
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 4.4.1 (RC) milestone Jul 13, 2021
@andrewbranch andrewbranch added the Rescheduled This issue was previously scheduled to an earlier milestone label Aug 30, 2021
@cory2067
Copy link

cory2067 commented Sep 7, 2021

I'm experiencing the same issue (same stack trace) so TS has been unusable for the past few days

Edit: Downgraded to 4.0.5 and now is working

@andrewbranch
Copy link
Member

Someone gave some info on how to repro: #43105 (comment)

Not sure if that’s actually enough to create a repro, but looking at guessDirectorySymlink, you can certainly imagine the loop running until aParts.length or bParts.length is less than 2. Let’s try to create a realistic repro from the comment above, but failing that, just fix it logically (terminate the loop when the remaining path parts get too short).

@shihabuddin
Copy link

I faced this issue after upgrading from 4.2.4 to 4.3.5. We have "typeRoots": ["node_modules/@types"]. But, we have .d.ts files under ./typings and my debugging revels that it happens from ./typings/index.d.ts.

@tychenjiajun
Copy link

Facing the same issue when typeRoots is included in tsconfig.json and called ts.getPreEmitDiagnostics(program). Upgrading ts to 4.5.0-beta fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants