perf_hooks: ignore duplicated entries in observer

PerformanceObserver should add to observing only unique entry types.

PR-URL: https://github.com/nodejs/node/pull/29442
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
This commit is contained in:
Kirill Fomichev authored and Michaël Zasso committed 2019-09-20 09:36:20 +02:00
1 parent 9b4a49c844
commit c146fff307
2 files changed
+7

No files matched your search

+1
View File
@@ -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);
@@ -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