File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed
Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ import { Cache } from "./cache";
1313import { showErrorPopup } from "./popup" ;
1414import { md5 , tempPath , toArray } from "./util" ;
1515
16+ const PARSER_TIMEOUT_MS = 30_000 ;
17+
1618const currentlyParsing = new Cache < string , Promise < AutocompleteResult > > ( 100 ) ;
1719const detected = new Cache <
1820 string ,
@@ -172,17 +174,29 @@ const runCommand = (command: string, args: string[]): Promise<string> => {
172174 [ command , ...args ] ,
173175 {
174176 cwd : __dirname ,
175- timeout : 5000 ,
177+ timeout : PARSER_TIMEOUT_MS ,
176178 } ,
177179 ( err , stdout , stderr ) => {
178180 if ( err === null ) {
179181 return resolve ( stdout ) ;
180182 }
181183
182- const errorMessage =
183- stderr . length > 0 ? stderr : stdout || err . message ;
184+ if ( err . killed ) {
185+ return reject (
186+ `Parser timed out after ${ PARSER_TIMEOUT_MS / 1000 } seconds. ` ,
187+ ) ;
188+ }
189+
190+ const details = [
191+ err . message ,
192+ stderr . length > 0 ? stderr . trim ( ) : null ,
193+ stdout . length > 0 ? stdout . trim ( ) : null ,
194+ err . code != null ? `exit code: ${ err . code } ` : null ,
195+ ]
196+ . filter ( Boolean )
197+ . join ( "\n" ) ;
184198
185- return reject ( errorMessage ) ;
199+ return reject ( details ) ;
186200 } ,
187201 ) ;
188202 } ) ;
You can’t perform that action at this time.
0 commit comments