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

Language server crashes handling file paths with Turkish I #35559

Closed
minestarks opened this issue Dec 7, 2019 · 2 comments
Closed

Language server crashes handling file paths with Turkish I #35559

minestarks opened this issue Dec 7, 2019 · 2 comments
Assignees
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Fix Available A PR has been opened for this issue

Comments

@minestarks
Copy link
Member

minestarks commented Dec 7, 2019

Repro: Open a file in VS Code with İ in the path, and an import statement

mkdir İ
cd İ
echo import { foo } from "bar" > foo.js
code .

Language service dies.

Impacts both VS and VS Code on both Windows and Mac OS.

In VS Code:


    No Project.

    Error: No Project.
        at Object.ThrowNoProject (%localappdata%\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:128093:23)
        at ProjectService.doEnsureDefaultProjectForFile (%localappdata%\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:131030:131)
        at ProjectService.ensureDefaultProjectForFile (%localappdata%\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:131025:75)
        at IOSession.Session.getFileAndProjectWorker (%localappdata%\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:134578:87)
        at IOSession.Session.getFileAndProject (%localappdata%\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:134561:29)
        at IOSession.Session.getApplicableRefactors (%localappdata%\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:135011:31)
        at Session.handlers.ts.createMapFromTemplate._a.<computed> (%localappdata%\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:133868:61)
        at c:\Users\mineyalc\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:135256:88
        at IOSession.Session.executeWithRequestId (%localappdata%\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:135247:28)
        at IOSession.Session.executeCommand (%localappdata%\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:135256:33)
        at IOSession.Session.onMessage (%localappdata%\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:135279:35)
        at Interface.<anonymous> (%localappdata%\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:136594:27)
        at Interface.emit (events.js:200:13)
        at Interface._onLine (readline.js:314:10)
        at Interface._normalWrite (readline.js:459:12)
        at Socket.ondata (readline.js:170:10)
        at Socket.emit (events.js:200:13)
        at addChunk (_stream_readable.js:294:12)
        at readableAddChunk (_stream_readable.js:275:11)
        at Socket.Readable.push (_stream_readable.js:210:10)
        at Pipe.onStreamRead (internal/stream_base_commons.js:166:17)

In VS (ADO bug)


getDirectoryToWatchFailedLookupLocation(tsserver.js:98851:26)
watchFailedLookupLocationOfResolution(tsserver.js:98919:31)
suppressed_frame()
watchFailedLookupLocationOfNonRelativeModuleResolutions(tsserver.js:98949:25)
suppressed_frame()
clearPerDirectoryResolutions(tsserver.js:98717:50)
Object.finishCachingPerDirectoryResolution(tsserver.js:98723:13)
ExternalProject.Project.updateGraphWorker(tsserver.js:135025:38)
ExternalProject.Project.updateGraph(tsserver.js:134966:42)
ExternalProject.updateGraph(tsserver.js:135963:59)
ProjectService.openExternalProject(tsserver.js:138655:29)
ProjectService.openExternalProjects(tsserver.js:138406:26)
Session.handlers.ts.createMapFromTemplate._a.(tsserver.js:139167:46)
unknown_function(tsserver.js:140854:88)
IOSession.Session.executeWithRequestId(tsserver.js:140845:28)
IOSession.Session.executeCommand(tsserver.js:140854:33)
IOSession.Session.onMessage(tsserver.js:140877:35)
Interface.(tsserver.js:142192:27)
suppressed_frame()
suppressed_frame()
suppressed_frame()
suppressed_frame()
suppressed_frame()
suppressed_frame()
suppressed_frame()
suppressed_frame()

The root cause is that the behavior of tolower() does not always match file system casing rules in case-insensitive file systems. To my knowledge, there is no API in Node.js or Windows that lets you access the actual casing rules. Furthermore, our check as to whether the file system is case-sensitive or not is rather naive and ignores possibilities like case-sensitive directories on Windows. Here are some best practices from Node.

While the true fix would be to always preserve casing for file paths in the language service, in practice special-casing "Turkish İ" will fix pretty much all occurrences of this issue.

@minestarks
Copy link
Member Author

May be a possible root cause of #33186

@minestarks
Copy link
Member Author

Related: #31819

@DanielRosenwasser DanielRosenwasser added the Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output label Jan 3, 2020
@sheetalkamat sheetalkamat added the Fix Available A PR has been opened for this issue label Jan 9, 2020
sheetalkamat added a commit that referenced this issue Jan 31, 2020
…tCanonicalFileName (#36106)

* Add test case to verify directory casing preservation when watching

* Fix unicode file name handling when watching failed lookup locations

* Add special file name lower conversion routine and use that instead of toLowerCase
Fixes #31819 and #35559

* Remove unicode from code

* Replace toLocaleLowerCase on filenames with ts.toFileNameLowerCase

* Make the intent of using toFileNameLowerCase more clear and why we make the restriction on turkish I with dot on top of it

* Update baselines for newly added tests in master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Fix Available A PR has been opened for this issue
Projects
None yet
Development

No branches or pull requests

4 participants