Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

droppedEntriesCount documentation incorrect #33506

Closed
tunetheweb opened this issue May 8, 2024 · 2 comments · Fixed by #33538
Closed

droppedEntriesCount documentation incorrect #33506

tunetheweb opened this issue May 8, 2024 · 2 comments · Fixed by #33538
Labels
Content:WebAPI Web API docs needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened.

Comments

@tunetheweb
Copy link
Contributor

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!

@tunetheweb tunetheweb added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label May 8, 2024
@github-actions github-actions bot added the Content:WebAPI Web API docs label May 8, 2024
@jasonwilliams
Copy link

jasonwilliams commented May 10, 2024

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

@tunetheweb
Copy link
Contributor Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants