File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -37,8 +37,12 @@ export function resetInstrumentationHandlers(): void {
3737/** Maybe run an instrumentation function, unless it was already called. */
3838export function maybeInstrument ( type : InstrumentHandlerType , instrumentFn : ( ) => void ) : void {
3939 if ( ! instrumented [ type ] ) {
40- instrumentFn ( ) ;
41- instrumented [ type ] = true ;
40+ try {
41+ instrumentFn ( ) ;
42+ instrumented [ type ] = true ;
43+ } catch ( e ) {
44+ DEBUG_BUILD && logger . error ( 'Error while instrumenting' , e ) ;
45+ }
4246 }
4347}
4448
Original file line number Diff line number Diff line change 1+ import { maybeInstrument } from '../src' ;
2+
3+ describe ( 'maybeInstrument' , ( ) => {
4+ test ( 'does not throw when instrumenting fails' , ( ) => {
5+ maybeInstrument ( 'xhr' , ( ) => {
6+ throw new Error ( 'test' ) ;
7+ } ) ;
8+ } ) ;
9+
10+ test ( 'does not throw when instrumenting fn is not a function' , ( ) => {
11+ maybeInstrument ( 'xhr' , undefined as any ) ;
12+ } ) ;
13+ } ) ;
You can’t perform that action at this time.
0 commit comments