Skip to content

Commit 89a38f9

Browse files
fixed timeout for server started checks #617 (#663)
fixed prettier rules
1 parent e54db0b commit 89a38f9

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

lib/check-started.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,25 @@ async function checkStarted(selenium, seleniumStatusUrl) {
1414
selenium.stderr.on('data', (d) => (cpState.stderr += d.toString()));
1515
}
1616

17-
const options = {
17+
const DEFAULT_SELENUIM_CHECK_STARTED_TIMEOUT = 60000; // 1minute
18+
const DEFAULT_SELENUIM_CHECK_STARTED_PAUSE = 500; // 0.5 second
19+
20+
const serverStartupTimeoutMS =
21+
parseInt(process.env.SELENUIM_CHECK_STARTED_TIMEOUT, 10) || DEFAULT_SELENUIM_CHECK_STARTED_TIMEOUT;
22+
23+
const serverStartupPauseMs =
24+
parseInt(process.env.SELENUIM_CHECK_STARTED_PAUSE, 10) || DEFAULT_SELENUIM_CHECK_STARTED_PAUSE;
25+
26+
const gotOptions = {
1827
responseType: 'json',
19-
timeout: 10000,
28+
timeout: serverStartupTimeoutMS,
2029
retry: 0,
2130
};
2231

23-
let attempts = 29;
32+
let attempts = serverStartupTimeoutMS / serverStartupPauseMs;
2433
const startTime = Date.now();
25-
while (attempts > 0 && Date.now() - startTime < 30000) {
26-
await sleep(500);
34+
while (attempts > 0 && Date.now() - startTime < serverStartupTimeoutMS) {
35+
await sleep(serverStartupPauseMs);
2736
attempts--;
2837

2938
if (cpState.exited) {
@@ -34,7 +43,7 @@ async function checkStarted(selenium, seleniumStatusUrl) {
3443

3544
try {
3645
// server has one minute to start
37-
await got(seleniumStatusUrl, options);
46+
await got(seleniumStatusUrl, gotOptions);
3847
selenium.removeListener('exit', errorIfNeverStarted);
3948
return null;
4049
} catch (err) {

0 commit comments

Comments
 (0)