File tree 2 files changed +24
-1
lines changed
testRunner/unittests/tsserver
2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -1974,7 +1974,7 @@ namespace ts.server {
1974
1974
// Read updated contents from disk
1975
1975
const configFilename = normalizePath ( project . getConfigFilePath ( ) ) ;
1976
1976
1977
- const configFileContent = this . host . readFile ( configFilename ) ! ; // TODO: GH#18217
1977
+ const configFileContent = this . host . readFile ( configFilename ) || "" ;
1978
1978
1979
1979
const result = parseJsonText ( configFilename , configFileContent ) ;
1980
1980
if ( ! result . endOfFileToken ) {
Original file line number Diff line number Diff line change @@ -1233,4 +1233,27 @@ declare var console: {
1233
1233
checkWatchedDirectories ( host , watchedRecursiveDirectories , /*recursive*/ true ) ;
1234
1234
} ) ;
1235
1235
} ) ;
1236
+
1237
+ describe ( "unittests:: tsserver:: ConfiguredProjects:: when reading tsconfig file fails" , ( ) => {
1238
+ it ( "should be tolerated without crashing the server" , ( ) => {
1239
+ const configFile = {
1240
+ path : `${ tscWatch . projectRoot } /tsconfig.json` ,
1241
+ content : ""
1242
+ } ;
1243
+ const file1 = {
1244
+ path : `${ tscWatch . projectRoot } /file1.ts` ,
1245
+ content : "let t = 10;"
1246
+ } ;
1247
+
1248
+ const host = createServerHost ( [ file1 , configFile ] ) ;
1249
+ const projectService = createProjectService ( host ) ;
1250
+ const originalReadFile = host . readFile ;
1251
+ host . readFile = f => {
1252
+ return f === configFile . path ?
1253
+ undefined :
1254
+ originalReadFile . call ( host , f ) ;
1255
+ } ;
1256
+ projectService . openClientFile ( file1 . path ) ;
1257
+ } ) ;
1258
+ } ) ;
1236
1259
}
You can’t perform that action at this time.
0 commit comments