File tree 2 files changed +23
-1
lines changed
2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,8 @@ const kDeprecationMessage =
72
72
const kTypeSingle = 0 ;
73
73
const kTypeMultiple = 1 ;
74
74
75
+ let gcTrackingInstalled = false ;
76
+
75
77
const kSupportedEntryTypes = ObjectFreeze ( [
76
78
'function' ,
77
79
'gc' ,
@@ -124,8 +126,11 @@ function maybeIncrementObserverCount(type) {
124
126
125
127
if ( observerType !== undefined ) {
126
128
observerCounts [ observerType ] ++ ;
127
- if ( observerType === NODE_PERFORMANCE_ENTRY_TYPE_GC )
129
+ if ( ! gcTrackingInstalled &&
130
+ observerType === NODE_PERFORMANCE_ENTRY_TYPE_GC ) {
128
131
installGarbageCollectionTracking ( ) ;
132
+ gcTrackingInstalled = true ;
133
+ }
129
134
}
130
135
}
131
136
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ require ( '../common' ) ;
4
+
5
+ // Verifies that setting up two observers to listen
6
+ // to gc performance does not crash.
7
+
8
+ const {
9
+ PerformanceObserver,
10
+ } = require ( 'perf_hooks' ) ;
11
+
12
+ // We don't actually care if the callback is ever invoked in this test
13
+ const obs = new PerformanceObserver ( ( ) => { } ) ;
14
+ const obs2 = new PerformanceObserver ( ( ) => { } ) ;
15
+
16
+ obs . observe ( { type : 'gc' } ) ;
17
+ obs2 . observe ( { type : 'gc' } ) ;
You can’t perform that action at this time.
0 commit comments