diff --git a/core/gather/session.js b/core/gather/session.js index 7ecc56553c65..81d1f3aea40f 100644 --- a/core/gather/session.js +++ b/core/gather/session.js @@ -93,7 +93,13 @@ class ProtocolSession extends CrdpEventEmitter { })); }); - const resultPromise = this._cdpSession.send(method, ...params); + const resultPromise = this._cdpSession.send(method, ...params).catch(err => { + // We set up our own protocol timeout system, so we should ignore protocol timeouts emitted by puppeteer. + // https://github.com/GoogleChrome/lighthouse/issues/15510 + if (/'protocolTimeout'/.test(err)) return; + + throw err; + }); const resultWithTimeoutPromise = Promise.race([resultPromise, timeoutPromise]); return resultWithTimeoutPromise.finally(() => { diff --git a/core/test/gather/session-test.js b/core/test/gather/session-test.js index fb026f93101f..2806399c6f34 100644 --- a/core/test/gather/session-test.js +++ b/core/test/gather/session-test.js @@ -27,10 +27,13 @@ describe('ProtocolSession', () => { let puppeteerSession; /** @type {ProtocolSession} */ let session; + let rawSend = fnAny(); beforeEach(() => { + rawSend = fnAny().mockResolvedValue(Promise.resolve()); + // @ts-expect-error - Individual mock functions are applied as necessary. - puppeteerSession = new CDPSessionImpl({_rawSend: fnAny(), send: fnAny()}, '', 'root'); + puppeteerSession = new CDPSessionImpl({_rawSend: rawSend}, '', 'root'); session = new ProtocolSession(puppeteerSession); }); @@ -162,6 +165,20 @@ describe('ProtocolSession', () => { expect(resultPromise).toBeDone(); expect(await resultPromise).toBe('result'); }); + + it('should ignore puppeteer protocol timeouts', async () => { + session.setNextProtocolTimeout(Infinity); + expect(session.hasNextProtocolTimeout()).toBe(true); + expect(session.getNextProtocolTimeout()).toBe(Infinity); + + // https://github.com/puppeteer/puppeteer/blob/28c1c2662a656a99c049218de4e7ab505c30f04f/packages/puppeteer-core/src/cdp/Connection.ts#L75 + rawSend.mockRejectedValue(new Error(`Increase the 'protocolTimeout' setting`)); + + await session.sendCommand('Page.navigate', {url: ''}); + + expect(session.hasNextProtocolTimeout()).toBe(false); + expect(session.getNextProtocolTimeout()).toBe(DEFAULT_TIMEOUT); + }); }); describe('.has/get/setNextProtocolTimeout', () => {