mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
perf_hooks: fix error message for invalid entryTypes
Will now print a more meaningful value instead of always [object Object] PR-URL: https://github.com/nodejs/node/pull/33285 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
94e5b5c77d
commit
1182539307
2 changed files with 7 additions and 6 deletions
|
@ -341,11 +341,12 @@ class PerformanceObserver extends AsyncResource {
|
|||
if (typeof options !== 'object' || options === null) {
|
||||
throw new ERR_INVALID_ARG_TYPE('options', 'Object', options);
|
||||
}
|
||||
if (!ArrayIsArray(options.entryTypes)) {
|
||||
throw new ERR_INVALID_OPT_VALUE('entryTypes', options);
|
||||
const { entryTypes } = options;
|
||||
if (!ArrayIsArray(entryTypes)) {
|
||||
throw new ERR_INVALID_OPT_VALUE('entryTypes', entryTypes);
|
||||
}
|
||||
const entryTypes = options.entryTypes.filter(filterTypes).map(mapTypes);
|
||||
if (entryTypes.length === 0) {
|
||||
const filteredEntryTypes = entryTypes.filter(filterTypes).map(mapTypes);
|
||||
if (filteredEntryTypes.length === 0) {
|
||||
throw new ERR_VALID_PERFORMANCE_ENTRY_TYPE();
|
||||
}
|
||||
this.disconnect();
|
||||
|
@ -353,7 +354,7 @@ class PerformanceObserver extends AsyncResource {
|
|||
this[kBuffer][kEntries] = [];
|
||||
L.init(this[kBuffer][kEntries]);
|
||||
this[kBuffering] = Boolean(options.buffered);
|
||||
for (const entryType of entryTypes) {
|
||||
for (const entryType of filteredEntryTypes) {
|
||||
const list = getObserversList(entryType);
|
||||
if (this[kTypes][entryType]) continue;
|
||||
const item = { obs: this };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue