@@ -55,7 +55,11 @@ export class PageCollector<T> {
5555 #maxNavigationSaved = 3 ;
5656 #includeAllPages?: boolean ;
5757
58-
58+ /**
59+ * This maps a Page to a list of navigations with a sub-list
60+ * of all collected resources.
61+ * The newer navigations come first.
62+ */
5963 protected storage = new WeakMap < Page , Array < Array < WithSymbolId < T > > > > ( ) ;
6064
6165 constructor (
@@ -120,8 +124,6 @@ export class PageCollector<T> {
120124 }
121125 } ;
122126
123- // await this.subscribeForIssues(page);
124-
125127 const listeners = this . #listenersInitializer( collector ) ;
126128
127129 listeners [ 'framenavigated' ] = ( frame : Frame ) => {
@@ -221,6 +223,9 @@ export class ConsoleCollector extends PageCollector<ConsoleMessage | Error | Agg
221223 #mockIssuesManagers = new WeakMap < Page , FakeIssuesManager > ( ) ;
222224
223225 override async addPage ( page : Page ) {
226+ if ( this . storage . has ( page ) ) {
227+ return ;
228+ }
224229 await super . addPage ( page ) ;
225230 await this . subscribeForIssues ( page ) ;
226231 }
@@ -245,7 +250,7 @@ export class ConsoleCollector extends PageCollector<ConsoleMessage | Error | Agg
245250 const session = await page . createCDPSession ( ) ;
246251 session . on ( 'Audits.issueAdded' , data => {
247252 // @ts -expect-error Types of protocol from Puppeteer and CDP are incopatible for Issues but it's the same type
248- const issue = createIssuesFromProtocolIssue ( null , data . issue , ) [ 0 ] ;
253+ const issue = createIssuesFromProtocolIssue ( null , data . issue ) [ 0 ] ;
249254 if ( ! issue ) {
250255 return ;
251256 }
0 commit comments