Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: fix regression in internal chrome error messages #15853

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/gather/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import EventEmitter from 'events';

import log from 'lighthouse-logger';

import {LighthouseError} from '../lib/lh-error.js';

// Controls how long to wait for a response after sending a DevTools protocol command.
Expand Down Expand Up @@ -107,6 +109,9 @@ class ProtocolSession extends CrdpEventEmitter {
const resultPromise = this._cdpSession.send(method, ...params, {
// Add 50ms to the Puppeteer timeout to ensure the Lighthouse timeout finishes first.
timeout: timeoutMs + PPTR_BUFFER,
}).catch((error) => {
log.formatProtocol('method <= browser ERR', {method}, 'error');
throw LighthouseError.fromProtocolMessage(method, error);
});
const resultWithTimeoutPromise = Promise.race([resultPromise, timeoutPromise]);

Expand Down
3 changes: 2 additions & 1 deletion core/test/gather/driver/target-manager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ describe('TargetManager', () => {
.mockResponse('Target.getTargetInfo', {targetInfo})
.mockResponse('Network.enable')
.mockResponse('Target.setAutoAttach', () => Promise.reject(fatalError));
await expect(targetManager.enable()).rejects.toMatchObject({message: 'Fatal error'});
await expect(targetManager.enable()).rejects.toThrowError(
'Protocol error (Target.setAutoAttach): Fatal error');

// Should still attempt to resume target.
expect(sendMock.findAllInvocations('Runtime.runIfWaitingForDebugger')).toHaveLength(1);
Expand Down
Loading