Skip to content

Commit 7bbfcee

Browse files
fix: ignore unmapped PerformanceIssue events
1 parent 728d902 commit 7bbfcee

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/PageCollector.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,11 @@ class PageEventSubscriber {
342342
#onIssueAdded = (data: Protocol.Audits.IssueAddedEvent) => {
343343
try {
344344
const inspectorIssue = data.issue;
345+
// DevTools currently defines this protocol issue code but has no
346+
// IssuesManager handler for it, so calling into the mapper only warns.
347+
if (String(inspectorIssue.code) === 'PerformanceIssue') {
348+
return;
349+
}
345350
const issue = DevTools.createIssuesFromProtocolIssue(
346351
null,
347352
// @ts-expect-error Protocol types diverge.

tests/PageCollector.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,37 @@ describe('ConsoleCollector', () => {
385385
assert.equal(data.length, 2);
386386
});
387387

388+
it('silently ignores unmapped PerformanceIssue events', async () => {
389+
const browser = getMockBrowser();
390+
const page = (await browser.pages())[0];
391+
// @ts-expect-error internal API.
392+
const cdpSession = page._client();
393+
const warnStub = sinon.stub(console, 'warn');
394+
395+
const collector = new ConsoleCollector(browser, collect => {
396+
return {
397+
issue: issue => {
398+
collect(issue as DevTools.AggregatedIssue);
399+
},
400+
} as ListenerMap;
401+
});
402+
await collector.init([page]);
403+
404+
const performanceIssue = {
405+
code: 'PerformanceIssue',
406+
details: {
407+
performanceIssueDetails: {
408+
performanceIssueType: 'DocumentCookie',
409+
},
410+
},
411+
} as unknown as Protocol.Audits.InspectorIssue;
412+
413+
cdpSession.emit('Audits.issueAdded', {issue: performanceIssue});
414+
415+
assert.equal(collector.getData(page).length, 0);
416+
sinon.assert.notCalled(warnStub);
417+
});
418+
388419
it('filters duplicated issues', async () => {
389420
const browser = getMockBrowser();
390421
const page = (await browser.pages())[0];

0 commit comments

Comments
 (0)