diff --git a/lib/perf_hooks.js b/lib/perf_hooks.js index 1bf635790e1332..12909b047ce20b 100644 --- a/lib/perf_hooks.js +++ b/lib/perf_hooks.js @@ -354,6 +354,7 @@ class PerformanceObserver extends AsyncResource { for (var n = 0; n < entryTypes.length; n++) { const entryType = entryTypes[n]; const list = getObserversList(entryType); + if (this[kTypes][entryType]) continue; const item = { obs: this }; this[kTypes][entryType] = item; L.append(list, item); diff --git a/test/parallel/test-performanceobserver.js b/test/parallel/test-performanceobserver.js index 513d7db220c0d1..75097cb8c77141 100644 --- a/test/parallel/test-performanceobserver.js +++ b/test/parallel/test-performanceobserver.js @@ -62,6 +62,12 @@ assert.strictEqual(counts[NODE_PERFORMANCE_ENTRY_TYPE_FUNCTION], 0); 'for option "entryTypes"' }); }); + + const obs = new PerformanceObserver(common.mustNotCall()); + obs.observe({ entryTypes: ['mark', 'mark'] }); + obs.disconnect(); + performance.mark('42'); + assert.strictEqual(counts[NODE_PERFORMANCE_ENTRY_TYPE_MARK], 0); } // Test Non-Buffered