@@ -74,6 +74,8 @@ namespace ts.server.typingsInstaller {
74
74
private readonly npmPath : string ;
75
75
readonly typesRegistry : Map < void > ;
76
76
77
+ private delayedInitializationError : InitializationFailedResponse ;
78
+
77
79
constructor ( globalTypingsCacheLocation : string , throttleLimit : number , log : Log ) {
78
80
super (
79
81
sys ,
@@ -99,13 +101,23 @@ namespace ts.server.typingsInstaller {
99
101
if ( this . log . isEnabled ( ) ) {
100
102
this . log . writeLine ( `Error updating ${ TypesRegistryPackageName } package: ${ ( < Error > e ) . message } ` ) ;
101
103
}
104
+ // store error info to report it later when it is known that server is already listening to events from typings installer
105
+ this . delayedInitializationError = {
106
+ kind : "event::initializationFailed" ,
107
+ message : ( < Error > e ) . message
108
+ } ;
102
109
}
103
110
104
111
this . typesRegistry = loadTypesRegistryFile ( getTypesRegistryFileLocation ( globalTypingsCacheLocation ) , this . installTypingHost , this . log ) ;
105
112
}
106
113
107
114
listen ( ) {
108
115
process . on ( "message" , ( req : DiscoverTypings | CloseProject ) => {
116
+ if ( this . delayedInitializationError ) {
117
+ // report initializationFailed error
118
+ this . sendResponse ( this . delayedInitializationError ) ;
119
+ this . delayedInitializationError = undefined ;
120
+ }
109
121
switch ( req . kind ) {
110
122
case "discover" :
111
123
this . install ( req ) ;
@@ -116,7 +128,7 @@ namespace ts.server.typingsInstaller {
116
128
} ) ;
117
129
}
118
130
119
- protected sendResponse ( response : SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes ) {
131
+ protected sendResponse ( response : SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes | InitializationFailedResponse ) {
120
132
if ( this . log . isEnabled ( ) ) {
121
133
this . log . writeLine ( `Sending response: ${ JSON . stringify ( response ) } ` ) ;
122
134
}
0 commit comments