microsoft / TypeScript

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

JS and TS language service die on template literal expression #42974

Open jklosinski opened 3 years ago

jklosinski commented 3 years ago

Issue Type: Bug

  1. Open VS Code, create a blank file, and set the language for the file to TypeScript.
  2. Paste in the following code which contains the problematic template literal expression (&$filter=${string}):

    export abstract class RecordStore<T> {
    
    constructor() {}
    
    async RetrieveMultiple(filter?: `&$filter=${string}` /* this template literal causes TS lang service to crash */) {
        if (this.LogicalName === "optionset") {
            debugger; // not valid
            return [];
        }
    
        let options = [
            `?$select=${this.QuerySelect}`,
            this.QueryExpand ? `&$expand=${this.QueryExpand}` : '',
            filter ?? "",
            this.QueryOrderBy ? `&$orderby=${this.QueryOrderBy}` : ''
        ].join('');
    
        return Xrm.WebApi.retrieveMultipleRecords(this.LogicalName, options).then(
            (results) => {
                let storedRecords = this.StoreDatabaseRecords(results.entities);
                return storedRecords;
            },
            (error) => {
                Controls.Messages.NotifyUser(error.message, "ERROR",
                    this.LogicalName + "_retrieveMultipleError");
                //Xrm.Utility.alertDialog(error.messages, <any>null);
                console.log(error);
                return [];
            }
        );
    }
    }
  3. Eventually VS shows error: "The TypeScript language service died 5 times right after it got started. The service will not be restarted."

VS Code version: Code 1.53.2 (622cb03f7e070a9670c94bae1a45d78d7181fbd4, 2021-02-11T11:48:20.056Z) OS version: Windows_NT ia32 10.0.18363

Extensions (7) Extension|Author (truncated)|Version ---|---|--- Bookmarks|ale|13.0.1 vscode-eslint|dba|2.1.14 prettier-vscode|esb|5.9.2 vscode-todo-plus|fab|4.18.2 csharp|ms-|1.23.9 vs-keybindings|ms-|0.2.0 vscode-todo-highlight|way|1.0.4 (4 theme extensions excluded)
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383:30185418 vspyt653:30253241 vspor879:30202332 vspor708:30202333 vspor363:30204092 vstry244:30256636 pythonvsdeb440:30248342 pythonvsded773:30248341 pythonvspyt600cf:30251589 ```
NotWearingPants commented 3 years ago

Doesn't repro for me, but sounds funny. Are you doing anything special like hovering something or autocomplete? Is this the whole code required for the crash? Does this occur when all extensions are disabled? (code --disable-extensions)

jklosinski commented 3 years ago

@NotWearingPants Yes, it happens even with extensions disabled. Yes, this is the only thing you need to do to cause the extension to crash, just paste in that code into a blank file that is set to TypeScript. Code shows in the status bar that I'm on TS version 4.1.5, are you on the same version?

mjbvz commented 3 years ago

Sometimes I see https://github.com/microsoft/TypeScript/issues/42613, however this is not specific to the code itself

I can't get the server to crash multiple times. This is with TS 4.1.5 with all extensions disabled. @polshgiant Do you see this in every project? What about in a new workspace with just that file?

jklosinski commented 3 years ago

@mjbvz Hmmph. Yes it happens in a brand new workspace with extensions disabled, just that TS file. I can do a screen recording if that would help...where would be a good place to post it though?

mjbvz commented 3 years ago

Please try collecting the TS Server log from the crashed instance:

  1. Set "typescript.tsserver.log": "verbose"
  2. Restart VS Code and reproduce the problem
  3. Open the TypeScript section of the output panel
  4. At the very top, find the first line that prints to path to the semantic error log file. It should look something like:

    [Info  - 19:54:59.247] <semantic> Log file: /Users/matb/Library/Application Support/Code - Insiders/logs/20200213T104930/exthost55/vscode.typescript-language-features/tsserver-log-ZT2zau/tsserver.log

    That file contains the typescript logs.

Look through that log file for the first error or stack trace you see. If you can share the log, I can also take a look to see if anything stands out

⚠️Warning: The TypeScript log may include information from your workspace, including file paths and source code. If you have any concerns about posting this publicly on Github, just let me know and we can arrange something else. On our side, we only use these logs to investigate issues like this

jklosinski commented 3 years ago

@mjbvz In the output window I see:

[Info  - 22:17:34.70] Starting TS Server 
[Info  - 22:17:34.70] Using tsserver from: c:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js
[Info  - 22:17:34.72] <syntax> Log file: c:\Users\Polshgiant\AppData\Roaming\Code\logs\20210222T072428\exthost4\vscode.typescript-language-features\tsserver-log-tIAq8O\tsserver.log
[Info  - 22:17:34.72] <syntax> Forking...
[Info  - 22:17:34.80] <syntax> Starting...
[Info  - 22:17:34.81] <semantic> Log file: c:\Users\Polshgiant\AppData\Roaming\Code\logs\20210222T072428\exthost4\vscode.typescript-language-features\tsserver-log-dNM0CC\tsserver.log
[Info  - 22:17:34.81] <semantic> Forking...
[Info  - 22:17:34.92] <semantic> Starting...
[Error  - 22:17:39.296] **TSServer exited with code: 3221225725**

and this repeats several times

Here is one of the semantic log files, nothing obvious is jumping out at me:

Info 0    [16:17:46.460] Starting TS Server
Info 1    [16:17:46.461] Version: 4.1.5
Info 2    [16:17:46.461] Arguments: C:\Program Files (x86)\Microsoft VS Code\Code.exe c:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName C:\Users\POLSHG~1\AppData\Local\Temp\vscode-typescript\c8a3c6f43a90ecb9ebca\tscancellation-b9c3105646e27c09d20a.tmp* --logVerbosity verbose --logFile c:\Users\Polshgiant\AppData\Roaming\Code\logs\20210222T072428\exthost4\vscode.typescript-language-features\tsserver-log-ORkZI1\tsserver.log --globalPlugins typescript-vscode-sh-plugin --pluginProbeLocations c:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\typescript-language-features --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation
Info 3    [16:17:46.486] Platform: win32 NodeVersion: 12 CaseSensitive: false
Info 4    [16:17:46.486] ServerMode: undefined syntaxOnly: false hasUnknownServerMode: undefined
Info 5    [16:17:46.488] Binding...
Info 6    [16:17:46.502] event:
    {"seq":0,"type":"event","event":"typingsInstallerPid","body":{"pid":10248}}
Info 7    [16:17:46.504] request:
    {"seq":0,"type":"request","command":"configure","arguments":{"hostInfo":"vscode","preferences":{"providePrefixAndSuffixTextForRename":true,"allowRenameOfImportPath":true,"includePackageJsonAutoImports":"auto"},"watchOptions":{}}}
Info 8    [16:17:46.504] Host information vscode
Info 9    [16:17:46.504] Host watch options changed to undefined, it will be take effect for next watches.
Info 10   [16:17:46.505] response:
    {"seq":0,"type":"response","command":"configure","request_seq":0,"success":true}
Perf 11   [16:17:46.505] 0::configure: async elapsed time (in milliseconds) 0.5708
Info 12   [16:17:46.505] request:
    {"seq":1,"type":"request","command":"compilerOptionsForInferredProjects","arguments":{"options":{"module":"commonjs","target":"es2016","jsx":"preserve","strictFunctionTypes":true,"sourceMap":true,"allowJs":true,"allowSyntheticDefaultImports":true,"allowNonTsExtensions":true,"resolveJsonModule":true}}}
Info 13   [16:17:46.506] Scheduled: *ensureProjectForOpenFiles*
Perf 14   [16:17:46.506] 1::compilerOptionsForInferredProjects: elapsed time (in milliseconds) 0.8706
Info 15   [16:17:46.506] response:
    {"seq":0,"type":"response","command":"compilerOptionsForInferredProjects","request_seq":1,"success":true,"body":true}
Info 16   [16:17:46.506] request:
    {"seq":2,"type":"request","command":"updateOpen","arguments":{"changedFiles":[],"closedFiles":[],"openFiles":[{"file":"^untitled:Untitled-1","fileContent":"export abstract class RecordStore<T> {\r\n    \r\n    constructor() {}\r\n\r\n    async RetrieveMultiple(filter?: `&$filter=${string}` /* this template literal causes TS lang service to crash */) {\r\n        if (this.LogicalName === \"optionset\") {\r\n            debugger; // not valid\r\n            return [];\r\n        }\r\n\r\n        let options = [\r\n            `?$select=${this.QuerySelect}`,\r\n            this.QueryExpand ? `&$expand=${this.QueryExpand}` : '',\r\n            filter ?? \"\",\r\n            this.QueryOrderBy ? `&$orderby=${this.QueryOrderBy}` : ''\r\n        ].join('');\r\n        \r\n        return Xrm.WebApi.retrieveMultipleRecords(this.LogicalName, options).then(\r\n            (results) => {\r\n                let storedRecords = this.StoreDatabaseRecords(results.entities);\r\n                return storedRecords;\r\n            },\r\n            (error) => {\r\n                Controls.Messages.NotifyUser(error.message, \"ERROR\",\r\n                    this.LogicalName + \"_retrieveMultipleError\");\r\n                //Xrm.Utility.alertDialog(error.messages, <any>null);\r\n                console.log(error);\r\n                return [];\r\n            }\r\n        );\r\n    }\r\n}","scriptKindName":"TS"}]}}
Info 17   [16:17:46.507] Search path: 
Info 18   [16:17:46.507] For info: ^untitled:Untitled-1 :: No config files found.
Info 19   [16:17:46.510] Loading global plugin typescript-vscode-sh-plugin
Info 20   [16:17:46.510] Enabling plugin typescript-vscode-sh-plugin from candidate paths: c:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\typescript-language-features,c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/tsserver.js/../../..
Info 21   [16:17:46.510] Loading typescript-vscode-sh-plugin from c:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\typescript-language-features (resolved to c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/typescript-language-features/node_modules)
Info 22   [16:17:46.523] typescript-vscode-sh-plugin initialized. Intercepting getEncodedSemanticClassifications and getEncodedSyntacticClassifications.
Info 23   [16:17:46.523] Plugin validation succeded
Info 24   [16:17:46.524] Starting updateGraphWorker: Project: /dev/null/inferredProject1*
Info 25   [16:17:46.539] DirectoryWatcher:: Added:: WatchInfo: c:/program files (x86)/microsoft vs code/resources/app/extensions/node_modules 1 undefined Project:  WatchType: node_modules for closed script infos in them
Info 26   [16:17:46.540] c for path c:/program files (x86)/microsoft vs code/resources/app/extensions/node_modules not found in cache...
Info 27   [16:17:46.540] Starting C:\Program Files (x86)\Microsoft VS Code\Code.exe with args:
    ["c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/watchGuard.js","c:/program files (x86)/microsoft vs code/resources/app/extensions/node_modules"]
Info 28   [16:17:46.667] WatchGuard for path c:/program files (x86)/microsoft vs code/resources/app/extensions/node_modules returned: OK
Info 29   [16:17:46.669] Elapsed:: 129.30069994926453ms DirectoryWatcher:: Added:: WatchInfo: c:/program files (x86)/microsoft vs code/resources/app/extensions/node_modules 1 undefined Project:  WatchType: node_modules for closed script infos in them
Info 30   [16:17:47.772] DirectoryWatcher:: Added:: WatchInfo: C:/Program Files (x86)/Microsoft VS Code/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots
Info 31   [16:17:47.772] watchDirectory for C:/Program Files (x86)/Microsoft VS Code/node_modules/@types uses cached drive information.
Info 32   [16:17:47.773] Elapsed:: 1.347700834274292ms DirectoryWatcher:: Added:: WatchInfo: C:/Program Files (x86)/Microsoft VS Code/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots
Info 33   [16:17:47.774] Finishing updateGraphWorker: Project: /dev/null/inferredProject1* Version: 1 structureChanged: true Elapsed: 1249.9268012046814ms
Info 34   [16:17:47.774] Project '/dev/null/inferredProject1*' (Inferred)
Info 35   [16:17:47.774]    Files (19)
    c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.es5.d.ts
    c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.es2015.d.ts
    c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.es2016.d.ts
    c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.dom.d.ts
    c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.dom.iterable.d.ts
    c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.webworker.importscripts.d.ts
    c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.scripthost.d.ts
    c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.es2015.core.d.ts
    c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.es2015.collection.d.ts
    c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.es2015.generator.d.ts
    c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.es2015.iterable.d.ts
    c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.es2015.promise.d.ts
    c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.es2015.proxy.d.ts
    c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.es2015.reflect.d.ts
    c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.es2015.symbol.d.ts
    c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts
    c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.es2016.array.include.d.ts
    c:/Program Files (x86)/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.es2016.full.d.ts
    ^untitled:Untitled-1

Info 36   [16:17:47.774] -----------------------------------------------
Info 37   [16:17:47.777] Project '/dev/null/inferredProject1*' (Inferred)
Info 37   [16:17:47.777]    Files (19)

Info 37   [16:17:47.777] -----------------------------------------------
Info 37   [16:17:47.777] Open files: 
Info 37   [16:17:47.778]    FileName: ^untitled:Untitled-1 ProjectRootPath: undefined
Info 37   [16:17:47.778]        Projects: /dev/null/inferredProject1*
Perf 37   [16:17:47.778] 2::updateOpen: elapsed time (in milliseconds) 1271.8280
Info 38   [16:17:47.778] response:
    {"seq":0,"type":"response","command":"updateOpen","request_seq":2,"success":true,"performanceData":{"updateGraphDurationMs":1249.9268012046814},"body":true}
Info 39   [16:17:47.778] request:
    {"seq":3,"type":"request","command":"projectInfo","arguments":{"file":"^untitled:Untitled-1","needFileNameList":false}}
Perf 40   [16:17:47.779] 3::projectInfo: elapsed time (in milliseconds) 0.4671
Info 41   [16:17:47.779] response:
    {"seq":0,"type":"response","command":"projectInfo","request_seq":3,"success":true,"body":{"configFileName":"/dev/null/inferredProject1*","languageServiceDisabled":false}}
Info 42   [16:17:47.779] request:
    {"seq":4,"type":"request","command":"geterr","arguments":{"delay":0,"files":["^untitled:Untitled-1"]}}
Perf 43   [16:17:47.780] 4::geterr: async elapsed time (in milliseconds) 0.7877
Info 44   [16:17:47.784] event:
    {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"^untitled:Untitled-1","diagnostics":[]}}
NotWearingPants commented 3 years ago

Maybe related to microsoft/vscode#117671? Common extensions are ESLint & Prettier, but I tried with both and still no repro..

mjbvz commented 3 years ago

Moving to TS to see if they have any ideas about the 3221225725 exit code

NotWearingPants commented 3 years ago

3221225725 = 0xc00000fd which (if interpreted as NTSTATUS) is a STATUS_STACK_OVERFLOW. Hmm