From 4465f4bd1900afc0b049ac863f4e372453a0c234 Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Tue, 28 Mar 2023 14:35:13 +0200 Subject: [PATCH] fix: increase the default protocol timeout (#9928) --- docs/api/puppeteer.browserconnectoptions.md | 2 +- .../puppeteer.browserconnectoptions.protocoltimeout.md | 2 +- packages/puppeteer-core/src/common/BrowserConnector.ts | 2 +- packages/puppeteer-core/src/common/Connection.ts | 9 +++++++-- packages/puppeteer-core/src/common/bidi/Connection.ts | 2 +- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/api/puppeteer.browserconnectoptions.md b/docs/api/puppeteer.browserconnectoptions.md index 190082d6c05..38d66a9c933 100644 --- a/docs/api/puppeteer.browserconnectoptions.md +++ b/docs/api/puppeteer.browserconnectoptions.md @@ -18,6 +18,6 @@ export interface BrowserConnectOptions | ---------------------------------------------------------------------------- | --------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ------- | | [defaultViewport?](./puppeteer.browserconnectoptions.defaultviewport.md) | | [Viewport](./puppeteer.viewport.md) \| null | _(Optional)_ Sets the viewport for each page. | | | [ignoreHTTPSErrors?](./puppeteer.browserconnectoptions.ignorehttpserrors.md) | | boolean | _(Optional)_ Whether to ignore HTTPS errors during navigation. | false | -| [protocolTimeout?](./puppeteer.browserconnectoptions.protocoltimeout.md) | | number | _(Optional)_ Timeout setting for individual protocol (CDP) calls. | 30000 | +| [protocolTimeout?](./puppeteer.browserconnectoptions.protocoltimeout.md) | | number | _(Optional)_ Timeout setting for individual protocol (CDP) calls. | 180000 | | [slowMo?](./puppeteer.browserconnectoptions.slowmo.md) | | number | _(Optional)_ Slows down Puppeteer operations by the specified amount of milliseconds to aid debugging. | | | [targetFilter?](./puppeteer.browserconnectoptions.targetfilter.md) | | [TargetFilterCallback](./puppeteer.targetfiltercallback.md) | _(Optional)_ Callback to decide if Puppeteer should connect to a given target or not. | | diff --git a/docs/api/puppeteer.browserconnectoptions.protocoltimeout.md b/docs/api/puppeteer.browserconnectoptions.protocoltimeout.md index b2de108177b..fa43dff6add 100644 --- a/docs/api/puppeteer.browserconnectoptions.protocoltimeout.md +++ b/docs/api/puppeteer.browserconnectoptions.protocoltimeout.md @@ -16,4 +16,4 @@ interface BrowserConnectOptions { #### Default value: -30000 +180000 diff --git a/packages/puppeteer-core/src/common/BrowserConnector.ts b/packages/puppeteer-core/src/common/BrowserConnector.ts index 397ec3e3a9d..b571c9de0ae 100644 --- a/packages/puppeteer-core/src/common/BrowserConnector.ts +++ b/packages/puppeteer-core/src/common/BrowserConnector.ts @@ -62,7 +62,7 @@ export interface BrowserConnectOptions { /** * Timeout setting for individual protocol (CDP) calls. * - * @defaultValue 30000 + * @defaultValue 180000 */ protocolTimeout?: number; } diff --git a/packages/puppeteer-core/src/common/Connection.ts b/packages/puppeteer-core/src/common/Connection.ts index d42ac877d58..f19bfb83d02 100644 --- a/packages/puppeteer-core/src/common/Connection.ts +++ b/packages/puppeteer-core/src/common/Connection.ts @@ -72,7 +72,12 @@ class Callback { this.#label = label; if (timeout) { this.#timer = setTimeout(() => { - this.#promise.reject(rewriteError(this.#error, `${label} timed out.`)); + this.#promise.reject( + rewriteError( + this.#error, + `${label} timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed.` + ) + ); }, timeout); } } @@ -194,7 +199,7 @@ export class Connection extends EventEmitter { super(); this.#url = url; this.#delay = delay; - this.#timeout = timeout ?? 30000; + this.#timeout = timeout ?? 180_000; this.#transport = transport; this.#transport.onmessage = this.onMessage.bind(this); diff --git a/packages/puppeteer-core/src/common/bidi/Connection.ts b/packages/puppeteer-core/src/common/bidi/Connection.ts index e86ace8c1ab..c690d640834 100644 --- a/packages/puppeteer-core/src/common/bidi/Connection.ts +++ b/packages/puppeteer-core/src/common/bidi/Connection.ts @@ -96,7 +96,7 @@ export class Connection extends EventEmitter { constructor(transport: ConnectionTransport, delay = 0, timeout?: number) { super(); this.#delay = delay; - this.#timeout = timeout; + this.#timeout = timeout ?? 180_000; this.#transport = transport; this.#transport.onmessage = this.onMessage.bind(this);