diff --git a/core/gather/driver/target-manager.js b/core/gather/driver/target-manager.js index 330198d42867..84ab913a6058 100644 --- a/core/gather/driver/target-manager.js +++ b/core/gather/driver/target-manager.js @@ -170,6 +170,10 @@ class TargetManager extends ProtocolEventEmitter { // Sometimes targets can be closed before we even have a chance to listen to their network activity. if (/Target closed/.test(err.message)) return; + // `Target.getTargetInfo` is not implemented for certain target types. + // Lighthouse isn't interested in these targets anyway so we can just ignore them. + if (/'Target.getTargetInfo' wasn't found/.test(err)) return; + // Worker targets can be a bit fickle and we only enable them for diagnostic purposes. // We shouldn't throw a fatal error if there were issues attaching to them. if (targetType === 'worker') { diff --git a/core/test/gather/driver/target-manager-test.js b/core/test/gather/driver/target-manager-test.js index 3f5eb96d7dea..50699f794c52 100644 --- a/core/test/gather/driver/target-manager-test.js +++ b/core/test/gather/driver/target-manager-test.js @@ -125,6 +125,21 @@ describe('TargetManager', () => { expect(sendMock.findAllInvocations('Runtime.runIfWaitingForDebugger')).toHaveLength(1); }); + it('should ignore errors if Target.getTargetInfo is undefined', async () => { + targetInfo.type = 'worker'; + sendMock + .mockResponse('Target.getTargetInfo', () => { + throw new Error(`'Target.getTargetInfo' wasn't found`); + }); + await targetManager.enable(); + + const invocations = sendMock.findAllInvocations('Target.setAutoAttach'); + expect(invocations).toHaveLength(0); + + // Should still be resumed. + expect(sendMock.findAllInvocations('Runtime.runIfWaitingForDebugger')).toHaveLength(1); + }); + it('should ignore targets that are not frames or web workers', async () => { targetInfo.type = 'service_worker'; sendMock