Skip to content

Commit ea57e86

Browse files
fix: ignore unmapped PerformanceIssue events (#1852)
## Summary - ignore Audits `PerformanceIssue` events before passing them to the DevTools IssuesManager mapper, which currently has no handler for that issue code - preserve the existing mapper/logging path for other issue codes - add regression coverage that `PerformanceIssue` is ignored without collecting an issue or writing a console warning Fixes #1850 ## Testing - `npm run build` - `npm run test:no-build -- tests/PageCollector.test.ts` - `npm run check-format` Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
1 parent 2f458c1 commit ea57e86

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-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

343343
#onIssueAdded = (inspectorIssue: Issue) => {
344344
try {
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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,35 @@ describe('ConsoleCollector', () => {
358358
assert.equal(data.length, 2);
359359
});
360360

361+
it('silently ignores unmapped PerformanceIssue events', async () => {
362+
const browser = getMockBrowser();
363+
const page = (await browser.pages())[0];
364+
const warnStub = sinon.stub(console, 'warn');
365+
366+
const collector = new ConsoleCollector(browser, collect => {
367+
return {
368+
devtoolsAggregatedIssue: issue => {
369+
collect(issue);
370+
},
371+
} as ListenerMap;
372+
});
373+
await collector.init([page]);
374+
375+
const performanceIssue = {
376+
code: 'PerformanceIssue',
377+
details: {
378+
performanceIssueDetails: {
379+
performanceIssueType: 'DocumentCookie',
380+
},
381+
},
382+
} as unknown as Protocol.Audits.InspectorIssue;
383+
384+
page.emit('issue', performanceIssue);
385+
386+
assert.equal(collector.getData(page).length, 0);
387+
sinon.assert.notCalled(warnStub);
388+
});
389+
361390
it('filters duplicated issues', async () => {
362391
const browser = getMockBrowser();
363392
const page = (await browser.pages())[0];

0 commit comments

Comments
 (0)