Skip to content

Commit 8b0fea7

Browse files
authored
feat(cli): add startServerReadyTimeout option (#246)
1 parent 5de8ec8 commit 8b0fea7

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/cli/src/collect/collect.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ function buildCommand(yargs) {
6161
type: 'string',
6262
default: 'listen|ready',
6363
},
64+
startServerReadyTimeout: {
65+
description: 'The number of milliseconds to wait for the server to start before continuing',
66+
type: 'number',
67+
default: 10000,
68+
},
6469
settings: {description: 'The Lighthouse settings and flags to use when collecting'},
6570
numberOfRuns: {
6671
alias: 'n',
@@ -115,13 +120,13 @@ async function startServerAndDetermineUrls(options) {
115120
const {child, patternMatch, stdout, stderr} = await runCommandAndWaitForPattern(
116121
options.startServerCommand,
117122
regexPattern,
118-
{timeout: 10000}
123+
{timeout: options.startServerReadyTimeout}
119124
);
120125
process.stdout.write(`Started a web server with "${options.startServerCommand}"...\n`);
121126
close = () => killProcessTree(child.pid);
122127

123128
if (!patternMatch) {
124-
// This is only for readability.
129+
// This `message` variable is only for readability.
125130
const message = `Ensure the server prints a pattern that matches ${regexPattern} when it is ready.\n`;
126131
process.stdout.write(`WARNING: Timed out waiting for the server to start listening.\n`);
127132
process.stdout.write(` ${message}`);

types/collect.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ declare global {
4343
staticDistDir?: string;
4444
isSinglePageApplication?: boolean;
4545
startServerCommand?: string;
46+
startServerReadyTimeout: number;
4647
startServerReadyPattern: string;
4748
chromePath?: string;
4849
puppeteerScript?: string;

0 commit comments

Comments
 (0)