Skip to content

Commit 9f7c776

Browse files
authored
Increase parser timeout and improve error messages on Windows (#619)
* Increase parser timeout and improve error messages on Windows * Fix code style --------- Co-authored-by: TitasGailius <[email protected]>
1 parent 1e42054 commit 9f7c776

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/support/parser.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { Cache } from "./cache";
1313
import { showErrorPopup } from "./popup";
1414
import { md5, tempPath, toArray } from "./util";
1515

16+
const PARSER_TIMEOUT_MS = 30_000;
17+
1618
const currentlyParsing = new Cache<string, Promise<AutocompleteResult>>(100);
1719
const 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
});

0 commit comments

Comments
 (0)