File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed 
src/performance-monitoring 
test/performance-monitoring Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -317,12 +317,9 @@ export class PerfEntryRecorder {
317317 } 
318318
319319 start ( type )  { 
320-  /** 
321-  * Safari throws an error when PerformanceObserver is 
322-  * observed for unknown entry types as longtasks and lcp is 
323-  * not supported at the moment 
324-  */ 
325-  try  { 
320+  const  supportedEntryTypes  = 
321+  window . PerformanceObserver ?. supportedEntryTypes  ||  [ ] 
322+  if  ( supportedEntryTypes . indexOf ( type )  !==  - 1 )  { 
326323 /** 
327324 * Start observing for different entry types depending on the transaction type 
328325 * - `buffered`: true means we would be able to retrive all the events that happened 
@@ -332,7 +329,7 @@ export class PerfEntryRecorder {
332329 * buffered flag (https://w3c.github.io/performance-timeline/#observe-method) 
333330 */ 
334331 this . po . observe ( {  type,  buffered : true  } ) 
335-  }   catch   ( _ )   { } 
332+  } 
336333 } 
337334
338335 stop ( )  { 
Original file line number Diff line number Diff line change @@ -191,6 +191,16 @@ describe('Metrics', () => {
191191 } ) 
192192 } ) 
193193
194+  it ( 'should not start observer with unsupported type' ,  ( )  =>  { 
195+  const  recorder  =  new  PerfEntryRecorder ( ( )  =>  { } ) 
196+  const  onStartSpy  =  jasmine . createSpy ( ) 
197+  recorder . po  =  { 
198+  observe : onStartSpy 
199+  } 
200+  recorder . start ( 'unknown_entry_type' ) 
201+  expect ( onStartSpy ) . not . toHaveBeenCalled ( ) 
202+  } ) 
203+ 
194204 describe ( 'Total Blocking Time' ,  ( )  =>  { 
195205 it ( 'should create total blocking time as span' ,  ( )  =>  { 
196206 calculateTotalBlockingTime ( longtaskEntries ) 
                                 You can’t perform that action at this time. 
               
                  
0 commit comments