File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
packages/replay/metrics/src Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,11 @@ export class MetricsCollector {
105105 const page = await browser . newPage ( ) ;
106106 disposeCallbacks . push ( ( ) => page . close ( ) ) ;
107107
108+ const errorLogs : Array < string > = [ ] ;
109+ await page . on ( 'console' , message => { if ( message . type ( ) === 'error' ) errorLogs . push ( message . text ( ) ) } ) ;
110+ await page . on ( 'crash' , _ => { errorLogs . push ( 'Page crashed' ) } ) ;
111+ await page . on ( 'pageerror' , error => { errorLogs . push ( `${ error . name } : ${ error . message } ` ) } ) ;
112+
108113 const cdp = await page . context ( ) . newCDPSession ( page ) ;
109114
110115 // Simulate throttling.
@@ -128,6 +133,10 @@ export class MetricsCollector {
128133 // NOTE: FID needs some interaction to actually show a value
129134 const vitals = await vitalsCollector . collect ( ) ;
130135
136+ if ( errorLogs . length > 0 ) {
137+ throw `Error logs in browser console:\n\t\t${ errorLogs . join ( '\n\t\t' ) } ` ;
138+ }
139+
131140 return new Metrics ( vitals , cpuSampler . getData ( ) , memSampler . getData ( ) ) ;
132141 } ) ( ) , {
133142 milliseconds : 60 * 1000 ,
You can’t perform that action at this time.
0 commit comments