content
content copied to clipboard
droppedEntriesCount documentation incorrect
MDN URL
https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver/PerformanceObserver
What specific section or headline is this issue about?
https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver/PerformanceObserver#droppedentriescount
What information was incorrect, unhelpful, or incomplete?
This page (added in #22318) says that droppedEntriesCount
is an optional property of PerformanceObserverCallback
but it's a nested property from within a PerformanceObserverCallbackOptions
.
What did you expect to see?
PerformanceObserverCallback
can return an optional [PerformanceObserverCallbackOptions](https://w3c.github.io/performance-timeline/#dom-performanceobservercallbackoptions)
dictionary property which will contain droppedEntriesCount
(when supported).
Do you have any supporting links, references, or citations?
The code sample is also wrong and should be like this:
function perfObserver(list, observer, options) {
list.getEntries().forEach((entry) => {
// do something with the entries
});
if (options?.droppedEntriesCount > 0) {
console.warn(
`${options?.droppedEntriesCount} entries got dropped due to the buffer being full.`,
);
}
}
const observer = new PerformanceObserver(perfObserver);
observer.observe({ type: "resource", buffered: true });
You can also see this in the spec: https://w3c.github.io/performance-timeline/#dom-performanceobservercallbackoptions
Do you have anything more you want to share?
I'd fix this myself, but seems a little complicated as to how PerformanceObserverCallback
would be set up and got a little lost when trying it myself.
Also not sure whether bcd should be updated to nest droppedEntriesCount
under PerformanceObserverCallbackOptions
or if it's fine to leave where it is?
All in all, could do with someone more familiar with the structure of MDN to tackle this.
Happy to help review any changes here though!
It looks like droppedEntriesCount
will only ever have a value (and be shown in options) on the first set of delivered entries. After that its undefined, I guess this is because you're unlikely to have dropped entries once you start emitting them through the observer (they no longer need to be buffered).
This should be mentioned on MDN if so. I've raised an issue here: https://issues.chromium.org/issues/339767457
As updated in https://issues.chromium.org/issues/339767457#comment2 I think you're correct that this is only set once. And agree it would be good to document in MDN as not the most obvious!