Skip to content

TSServer errors for in-memory only resource #21204

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
mjbvz opened this issue Jan 16, 2018 · 19 comments
Closed

TSServer errors for in-memory only resource #21204

mjbvz opened this issue Jan 16, 2018 · 19 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue High Priority VS Code Tracked There is a VS Code equivalent to this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Jan 16, 2018

TypeScript Version: 2.7.0-dev.20180108

From microsoft/vscode#40915 (comment)

Repo

  1. Open VS Code
  2. Open interactive playground
  3. Try triggering intellisense in one of the JS/TS sections

These files are implemented using a custom uri scheme walkThroughSnippet that only exists in-memory

Expected behavior:
Works as expected.

Actual behavior:
Errors on these files

[Trace  - 11:18:51] Sending request: navtree (11). Response expected: yes. Current queue length: 7
Arguments: {
    "file": "walkThroughSnippet:/Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/parts/welcome/walkThrough/electron-browser/editor/vs_code_editor_walkthrough.md#1.js"
}
[Trace  - 11:18:51] Response received: navtree (11). Request took 414 ms. Success: false . Message: Error processing request. Debug Failure. False expression: Script info with non-dynamic relative file name can only be open script info
Error: Debug Failure. False expression: Script info with non-dynamic relative file name can only be open script info
    at ProjectService.getOrCreateScriptInfoWorker (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:86857:30)
    at ProjectService.getOrCreateScriptInfoNotOpenedByClientForNormalizedPath (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:86843:29)
    at ProjectService.getOrCreateScriptInfoNotOpenedByClient (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:86823:29)
    at InferredProject.Project.getOrCreateScriptInfoAndAttachToProject (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:84850:54)
    at InferredProject.Project.getScriptSnapshot (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:84870:39)
    at SyntaxTreeCache.getCurrentSourceFile (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:81705:44)
    at Object.getNavigationTree (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:82196:71)
    at IOSession.Session.getNavigationTree (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:88735:44)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:87756:61)
    at /Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:89032:88
    at IOSession.Session.executeWithRequestId (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:89023:28)
    at IOSession.Session.executeCommand (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:89032:33)
    at IOSession.Session.onMessage (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:89052:35)
    at Interface.<anonymous> (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:90253:27)
    at emitOne (events.js:96:13)
    at Interface.emit (events.js:191:7)
    at Interface._onLine (readline.js:241:10)
    at Interface._normalWrite (readline.js:384:12)
    at Socket.ondata (readline.js:101:10)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:178:18)
    at Socket.Readable.push (_stream_readable.js:136:10)
    at Pipe.onread (net.js:560:20)

Here's the complete tsserver log: tsserver.log

tsserver.log

@mjbvz mjbvz added the VS Code Tracked There is a VS Code equivalent to this issue label Jan 16, 2018
@mhegazy mhegazy added the Bug A bug in TypeScript label Jan 17, 2018
@mhegazy mhegazy added this to the TypeScript 2.7.1 milestone Jan 17, 2018
@sheetalkamat
Copy link
Member

@mjbvz currently we have notion called dynamic files and that uses file names that start with ^. Is it easy on your side to name the file as ^walkThroughSnippet:/Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/parts/welcome/walkThrough/electron-browser/editor/vs_code_editor_walkthrough.md#1.js and leverage the same concept?

@mjbvz
Copy link
Contributor Author

mjbvz commented Jan 17, 2018

Yes, that would be a fairly easy change on the vscode side. Was this added in 2.7? Should we also do this for untitled files?

@sheetalkamat
Copy link
Member

#17791 added this as we need files to represent debugger created memory only files.

@mjbvz
Copy link
Contributor Author

mjbvz commented Jan 17, 2018

Tried making suggested change to send untitled documents as ^untitled:..., but hitting tsserver errors. Full trace:

[Info  - 1:51:04 PM] Using tsserver from: /Users/matb/projects/vscode/extensions/node_modules/typescript/lib
[Info  - 1:51:04 PM] TSServer log file: /Users/matb/Library/Application Support/code-oss-dev/logs/20180117T134756/vscode.typescript/tsserver-log-2F6Otu/tsserver.log
[Info  - 1:51:04 PM] Forking TSServer
PATH: /Users/matb/.nvm/versions/node/v8.9.1/bin:/usr/local/opt/opencv3/bin:/Users/matb/Library/Python/2.7/bin:/Users/matb/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:/opt/X11/bin
[Info  - 1:51:04 PM] Started TSServer
[Trace  - 1:51:04 PM] Sending request: configure (0). Response expected: yes. Current queue length: 0
Arguments: {
    "hostInfo": "vscode"
}
[Trace  - 1:51:04 PM] Event received: typingsInstallerPid (0).
Data: {
    "pid": 82240
}
[Trace  - 1:51:04 PM] Response received: configure (0). Request took 415 ms. Success: true 
[Trace  - 1:51:04 PM] Sending request: compilerOptionsForInferredProjects (1). Response expected: yes. Current queue length: 2
Arguments: {
    "options": {
        "module": "commonjs",
        "target": "es2016",
        "jsx": "preserve",
        "experimentalDecorators": true,
        "allowJs": true,
        "allowSyntheticDefaultImports": true,
        "allowNonTsExtensions": true
    }
}
[Trace  - 1:51:04 PM] Response received: compilerOptionsForInferredProjects (1). Request took 418 ms. Success: true 
Result: true
[Trace  - 1:51:04 PM] Sending request: open (2). Response expected: no. Current queue length: 1
Arguments: {
    "file": "^untitled:Untitled-1",
    "fileContent": "",
    "scriptKindName": "TS",
    "projectRootPath": "/Users/matb/projects/san"
}
[Trace  - 1:51:04 PM] Sending request: geterr (3). Response expected: no. Current queue length: 0
Arguments: {
    "delay": 0,
    "files": [
        "^untitled:Untitled-1"
    ]
}
[Trace  - 1:51:04 PM] Event received: requestCompleted (0).
Data: {
    "request_seq": 3
}
[Trace  - 1:51:26 PM] Sending request: navtree (4). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "^untitled:Untitled-1"
}
[Trace  - 1:51:26 PM] Response received: navtree (4). Request took 3 ms. Success: false . Message: Error processing request. Cannot read property 'isOrphan' of undefined
TypeError: Cannot read property 'isOrphan' of undefined
    at ProjectService.getDefaultProjectForFile (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:86100:63)
    at IOSession.Session.getFileAndLanguageServiceForSyntacticOperation (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:88407:92)
    at IOSession.Session.getNavigationTree (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:88734:31)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:87756:61)
    at /Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:89032:88
    at IOSession.Session.executeWithRequestId (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:89023:28)
    at IOSession.Session.executeCommand (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:89032:33)
    at IOSession.Session.onMessage (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:89052:35)
    at Interface.<anonymous> (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:90253:27)
    at emitOne (events.js:96:13)
    at Interface.emit (events.js:191:7)
    at Interface._onLine (readline.js:241:10)
    at Interface._normalWrite (readline.js:384:12)
    at Socket.ondata (readline.js:101:10)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:178:18)
    at Socket.Readable.push (_stream_readable.js:136:10)
    at Pipe.onread (net.js:560:20)
[Trace  - 1:51:26 PM] Sending request: completions (5). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "^untitled:Untitled-1",
    "line": 1,
    "offset": 1,
    "includeExternalModuleExports": true,
    "includeInsertTextCompletions": true
}
[Error  - 1:51:26 PM] 'navtree' request failed with error.
Error processing request. Cannot read property 'isOrphan' of undefined
TypeError: Cannot read property 'isOrphan' of undefined
    at ProjectService.getDefaultProjectForFile (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:86100:63)
    at IOSession.Session.getFileAndLanguageServiceForSyntacticOperation (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:88407:92)
    at IOSession.Session.getNavigationTree (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:88734:31)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:87756:61)
    at /Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:89032:88
    at IOSession.Session.executeWithRequestId (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:89023:28)
    at IOSession.Session.executeCommand (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:89032:33)
    at IOSession.Session.onMessage (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:89052:35)
    at Interface.<anonymous> (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:90253:27)
    at emitOne (events.js:96:13)
    at Interface.emit (events.js:191:7)
    at Interface._onLine (readline.js:241:10)
    at Interface._normalWrite (readline.js:384:12)
    at Socket.ondata (readline.js:101:10)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:178:18)
    at Socket.Readable.push (_stream_readable.js:136:10)
    at Pipe.onread (net.js:560:20)
[Trace  - 1:51:26 PM] Response received: completions (5). Request took 6 ms. Success: false . Message: Error processing request. No Project.
Error: No Project.
    at Object.ThrowNoProject (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:83346:23)
    at ProjectService.getDefaultProjectForFile (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:86104:46)
    at IOSession.Session.getFileAndProjectWorker (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:88418:87)
    at IOSession.Session.getFileAndProject (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:88403:29)
    at IOSession.Session.getCompletions (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:88559:31)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:87667:61)
    at /Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:89032:88
    at IOSession.Session.executeWithRequestId (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:89023:28)
    at IOSession.Session.executeCommand (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:89032:33)
    at IOSession.Session.onMessage (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:89052:35)
    at Interface.<anonymous> (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:90253:27)
    at emitOne (events.js:96:13)
    at Interface.emit (events.js:191:7)
    at Interface._onLine (readline.js:241:10)
    at Interface._normalWrite (readline.js:384:12)
    at Socket.ondata (readline.js:101:10)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:178:18)
    at Socket.Readable.push (_stream_readable.js:136:10)
    at Pipe.onread (net.js:560:20)
[Error  - 1:51:26 PM] 'completions' request failed with error.
Error processing request. No Project.
Error: No Project.
    at Object.ThrowNoProject (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:83346:23)
    at ProjectService.getDefaultProjectForFile (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:86104:46)
    at IOSession.Session.getFileAndProjectWorker (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:88418:87)
    at IOSession.Session.getFileAndProject (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:88403:29)
    at IOSession.Session.getCompletions (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:88559:31)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:87667:61)
    at /Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:89032:88
    at IOSession.Session.executeWithRequestId (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:89023:28)
    at IOSession.Session.executeCommand (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:89032:33)
    at IOSession.Session.onMessage (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:89052:35)
    at Interface.<anonymous> (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:90253:27)
    at emitOne (events.js:96:13)
    at Interface.emit (events.js:191:7)
    at Interface._onLine (readline.js:241:10)
    at Interface._normalWrite (readline.js:384:12)
    at Socket.ondata (readline.js:101:10)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:178:18)
    at Socket.Readable.push (_stream_readable.js:136:10)
    at Pipe.onread (net.js:560:20)

@sheetalkamat
Copy link
Member

I think thats because the projectRootPath is set? Can you please try not setting projectRootPath in the request. Thanks.
The dynamic files till now were always created in their own external project with same name as dynamic file.. Hence they expect the projectRootPath to be not set.. Because otherwise we wont be able to distinguish between "^untitled:Untitled-1" with projectRootPath as "/user/username/somefolder" and "^untitled:Untitled-1" with projectRoot path as "/user/username/anotherfolder"

@mjbvz
Copy link
Contributor Author

mjbvz commented Jan 18, 2018

Ok, gave that a try and it fixed untitled files but not the interactive playground files for some reason. Here's the ts server log: tsserver.log

Main error:

[Error  - 5:08:53 PM] 'quickinfo' request failed with error.
Error processing request. Cannot read property 'getMissingFilePaths' of undefined
TypeError: Cannot read property 'getMissingFilePaths' of undefined
    at Object.updateMissingFilePathsWatch (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:85342:39)
    at InferredProject.Project.updateGraphWorker (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:86629:24)
    at InferredProject.Project.updateGraph (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:86557:39)
    at InferredProject.Project.getLanguageService (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:86271:26)
    at IOSession.Session.getQuickInfoWorker (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:89793:41)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:88950:61)
    at /Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:90358:88
    at IOSession.Session.executeWithRequestId (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:90349:28)
    at IOSession.Session.executeCommand (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:90358:33)
    at IOSession.Session.onMessage (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:90378:35)
    at Interface.<anonymous> (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:91579:27)
    at emitOne (events.js:96:13)
    at Interface.emit (events.js:191:7)
    at Interface._onLine (readline.js:241:10)
    at Interface._normalWrite (readline.js:384:12)
    at Socket.ondata (readline.js:101:10)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:178:18)
    at Socket.Readable.push (_stream_readable.js:136:10)
    at Pipe.onread (net.js:560:20)

@sheetalkamat
Copy link
Member

@mjbvz can you please try tsserver.js built from branch https://github.com/Microsoft/TypeScript/tree/detailDebugFail to get more detailed information. I see assert in the log but cant tell from it whats going on. The mock test i created seems to be running ok.

 {\n    res.send(`Hello ${req.}`);\n});\n\napp.listen(3000);","scriptKindName":"JS"}}:

    Debug Failure. False expression: Script info with non-dynamic relative file name can only be open script info

    Error: Debug Failure. False expression: Script info with non-dynamic relative file name can only be open script info

@mjbvz
Copy link
Contributor Author

mjbvz commented Jan 19, 2018

Hey, I don't see that branch on Microsoft/TypeScript. Did you just push it today?

@sheetalkamat
Copy link
Member

I am sorry, i merged that PR and deleted the branch without realizing that i shared it with you here. Is it possible to use latest build. That should contain the detailed debug failure to investigate further..

@mjbvz
Copy link
Contributor Author

mjbvz commented Jan 19, 2018

Here's the updated log with the latest ts build from master: tsserver.log

@sheetalkamat
Copy link
Member

Ok thats because the files are called dynamic if their baseName starts with "^" And the name of the file is ^walkThroughSnippet:/Users/matb/projects/vscode/out/vs/workbench/parts/welcome/walkThrough/electron-browser/editor/vs_code_editor_walkthrough.md#1.js and since the baseFileName is vs_code_editor_walkthrough.md#1.js which is not dynamic the assert. So you want to pass the name of the file as walkThroughSnippet:/Users/matb/projects/vscode/out/vs/workbench/parts/welcome/walkThrough/electron-browser/editor/^vs_code_editor_walkthrough.md#1.js

@sheetalkamat
Copy link
Member

Also while looking at this i realised that that even after changing this you would run into more issues. The reason being the scenario for dynamic file always uses external project.. So you should be creating external project with name ^vs_code_editor_walkthrough.md#1.js and have it contain a file ^vs_code_editor_walkthrough.md#1.js. Eg. look at the test: https://github.com/Microsoft/TypeScript/blob/master/src/harness/unittests/tsserverProjectSystem.ts#L1189

@mhegazy
Copy link
Contributor

mhegazy commented Jan 20, 2018

So you should be creating external project with name ^vs_code_editor_walkthrough.md#1.js and have it contain a file

I do not think we should require that. why can not we just make the inferred project scenario work for them?

@mjbvz
Copy link
Contributor Author

mjbvz commented Jan 20, 2018

Yes, that would be a non-trivial change on our side. Could we perhaps add a flag on the TSServer open request to mark a resource as in-memory?

@sheetalkamat
Copy link
Member

@mhegazy we could make it non required and project with dynamic file as root to have current directory to be tsserver current directory

@sheetalkamat
Copy link
Member

@mjbvz taking the flag means we need to store the info .. currently we are in good spot of detecting the in memory based on file name .. I think we could make file as dynamic if the name irrespective of base starts with ^

@mhegazy
Copy link
Contributor

mhegazy commented Jan 20, 2018

we could make it non required and project with dynamic file as root to have current directory to be tsserver current directory

That sounds better than requiring VSCode to create an external project.

@sheetalkamat
Copy link
Member

@mjbvz can you please give #21338 try and see if it works for you.

@mjbvz
Copy link
Contributor Author

mjbvz commented Jan 22, 2018

@sheetalkamat Just tested that branch and the interactive playground seems to be working now. Here's the change on our side: microsoft/vscode#42001

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jan 24, 2018
sheetalkamat added a commit that referenced this issue Jan 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue High Priority VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

3 participants