Skip to content

Commit

Permalink
perf_hooks: ignore duplicated entries in observer
Browse files Browse the repository at this point in the history
PerformanceObserver should add to observing only unique entry types.

PR-URL: #29442
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
  • Loading branch information
fanatid authored and Trott committed Sep 7, 2019
1 parent 6d01f1f commit ef9ecfb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/perf_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
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

0 comments on commit ef9ecfb

Please sign in to comment.