@@ -66,7 +66,7 @@ namespace ServerState {
6666 * Version reported by currently-running tsserver.
6767 */
6868 public tsserverVersion : string | undefined ,
69- public langaugeServiceEnabled : boolean ,
69+ public languageServiceEnabled : boolean ,
7070 ) { }
7171
7272 public readonly toCancelOnResourceChange = new Set < ToCancelOnResourceChanged > ( ) ;
@@ -75,15 +75,16 @@ namespace ServerState {
7575 this . tsserverVersion = tsserverVersion ;
7676 }
7777
78- updateLangaugeServiceEnabled ( enabled : boolean ) {
79- this . langaugeServiceEnabled = enabled ;
78+ updateLanguageServiceEnabled ( enabled : boolean ) {
79+ this . languageServiceEnabled = enabled ;
8080 }
8181 }
8282
8383 export class Errored {
8484 readonly type = Type . Errored ;
8585 constructor (
8686 public readonly error : Error ,
87+ public readonly tsServerLogFile : string | undefined ,
8788 ) { }
8889 }
8990
@@ -364,7 +365,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
364365 vscode . window . showErrorMessage ( localize ( 'serverExitedWithError' , 'TypeScript language server exited with error. Error message is: {0}' , err . message || err . name ) ) ;
365366 }
366367
367- this . serverState = new ServerState . Errored ( err ) ;
368+ this . serverState = new ServerState . Errored ( err , handle . tsServerLogFile ) ;
368369 this . error ( 'TSServer errored with error.' , err ) ;
369370 if ( handle . tsServerLogFile ) {
370371 this . error ( `TSServer log file: ${ handle . tsServerLogFile } ` ) ;
@@ -580,7 +581,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
580581
581582 if ( item === reportIssueItem ) {
582583 const args = previousState . type === ServerState . Type . Errored && previousState . error instanceof TypeScriptServerError
583- ? getReportIssueArgsForError ( previousState . error )
584+ ? getReportIssueArgsForError ( previousState . error , previousState . tsServerLogFile )
584585 : undefined ;
585586 vscode . commands . executeCommand ( 'workbench.action.openIssueReporter' , args ) ;
586587 }
@@ -750,9 +751,10 @@ export default class TypeScriptServiceClient extends Disposable implements IType
750751
751752 if ( this . serverState . type === ServerState . Type . Running ) {
752753 this . info ( 'Killing TS Server' ) ;
754+ const logfile = this . serverState . server . tsServerLogFile ;
753755 this . serverState . server . kill ( ) ;
754756 if ( error instanceof TypeScriptServerError ) {
755- this . serverState = new ServerState . Errored ( error ) ;
757+ this . serverState = new ServerState . Errored ( error , logfile ) ;
756758 }
757759 }
758760 }
@@ -789,7 +791,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
789791 {
790792 const body = ( event as Proto . ProjectLanguageServiceStateEvent ) . body ! ;
791793 if ( this . serverState . type === ServerState . Type . Running ) {
792- this . serverState . updateLangaugeServiceEnabled ( body . languageServiceEnabled ) ;
794+ this . serverState . updateLanguageServiceEnabled ( body . languageServiceEnabled ) ;
793795 }
794796 this . _onProjectLanguageServiceStateChanged . fire ( body ) ;
795797 break ;
@@ -883,30 +885,60 @@ export default class TypeScriptServiceClient extends Disposable implements IType
883885 }
884886}
885887
886- function getReportIssueArgsForError ( error : TypeScriptServerError ) : { extensionId : string , issueTitle : string , issueBody : string } | undefined {
888+ function getReportIssueArgsForError (
889+ error : TypeScriptServerError ,
890+ logPath : string | undefined ,
891+ ) : { extensionId : string , issueTitle : string , issueBody : string } | undefined {
887892 if ( ! error . serverStack || ! error . serverMessage ) {
888893 return undefined ;
889894 }
890895
891896 // Note these strings are intentionally not localized
892897 // as we want users to file issues in english
893- return {
894- extensionId : 'vscode.typescript-language-features' ,
895- issueTitle : `TS Server fatal error: ${ error . serverMessage } ` ,
896898
897- issueBody : `**TypeScript Version:** ${ error . version . apiVersion ?. fullVersionString }
898-
899- **Steps to reproduce crash**
899+ const sections = [
900+ `❗️❗️❗️ Please fill in the sections below to help us diagnose the issue ❗️❗️❗️` ,
901+ `**TypeScript Version:** ${ error . version . apiVersion ?. fullVersionString } ` ,
902+ `**Steps to reproduce crash**
900903
9019041.
9029052.
903- 3.
906+ 3.` ,
907+ ] ;
908+
909+ if ( logPath ) {
910+ sections . push ( `**TS Server Log**
904911
905- **TS Server Error Stack**
912+ ❗️ Please review and upload this log file to help us diagnose this crash:
913+
914+ \`${ logPath } \`
915+
916+ 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.
917+ ` ) ;
918+ } else {
919+
920+ sections . push ( `**TS Server Log**
921+
922+ Server logging disabled. To help us fix crashes like this, please enable logging by setting:
923+
924+ \`\`\`json
925+ "typescript.tsserver.log": "verbose"
926+ \`\`\`
927+
928+ After enabling this setting, future crash reports will include the server log.` ) ;
929+ }
930+
931+ sections . push ( `**TS Server Error Stack**
906932
907933\`\`\`
908934${ error . serverStack }
909- \`\`\`` ,
935+ \`\`\`` ) ;
936+
937+ return {
938+ extensionId : 'vscode.typescript-language-features' ,
939+ issueTitle : `TS Server fatal error: ${ error . serverMessage } ` ,
940+
941+ issueBody : sections . join ( '\n\n' )
910942 } ;
911943}
912944
0 commit comments