Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
perf_hooks: ignore duplicated entries in observer
PerformanceObserver should add to observing only unique entry types.
  • Loading branch information
fanatid committed Sep 4, 2019
commit 011bfb4b9616cc24e6b7a859df1b8a7f2d14e09e
1 change: 1 addition & 0 deletions lib/perf_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,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);
Expand Down
6 changes: 6 additions & 0 deletions test/parallel/test-performanceobserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down