From 6a89a2aadcaf683fe57f1e0e13886f1fa937e194 Mon Sep 17 00:00:00 2001 From: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com> Date: Thu, 29 Jun 2023 17:34:20 +0200 Subject: [PATCH] fix: negative timeout doesn't break launch (#10480) --- packages/browsers/src/launch.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/browsers/src/launch.ts b/packages/browsers/src/launch.ts index 9f8c8f20ed2..b26e222e3aa 100644 --- a/packages/browsers/src/launch.ts +++ b/packages/browsers/src/launch.ts @@ -368,7 +368,7 @@ export class Process { this.#clearListeners(); } - waitForLineOutput(regex: RegExp, timeout?: number): Promise { + waitForLineOutput(regex: RegExp, timeout = 0): Promise { 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) {