fix: negative timeout doesn't break launch (#10480)

This commit is contained in:
Nikolay Vitkov 2023-06-29 17:34:20 +02:00 committed by GitHub
parent 25cb642623
commit 6a89a2aadc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -368,7 +368,7 @@ export class Process {
this.#clearListeners();
}
waitForLineOutput(regex: RegExp, timeout?: number): Promise<string> {
waitForLineOutput(regex: RegExp, timeout = 0): Promise<string> {
if (!this.#browserProcess.stderr) {
throw new Error('`browserProcess` does not have stderr.');
}
@ -380,7 +380,8 @@ export class Process {
rl.on('close', onClose);
this.#browserProcess.on('exit', onClose);
this.#browserProcess.on('error', onClose);
const timeoutId = timeout ? setTimeout(onTimeout, timeout) : 0;
const timeoutId =
timeout > 0 ? setTimeout(onTimeout, timeout) : undefined;
const cleanup = (): void => {
if (timeoutId) {