WICG / pending-beacon

A better beaconing API
Other
43 stars 8 forks source link

[Fetch-Based API] Handling Request Size Limit #76

Closed mingyc closed 9 months ago

mingyc commented 1 year ago

Context: #70 #71

As setting deferSend implies keepalive is also true, such request has to share the same size limit budget as a regular keepalive request’s one: "for each fetch group, the sum of contentLength and inflightKeepaliveBytes <= 64 KB".

To comply with the limit, there are several options:

  1. fetch() throws TypeError whenever the budget has exceeded. Users will not be able to create new pending requests.
  2. The browser forces sending out other existing pending requests, in FIFO order, when the budget has exceeded. For a single request > 64KB, fetch() should still throws TypeError.
  3. Ignore the size limit if BackgroundFetch Permission is enabled for the page.
mingyc commented 1 year ago

Today's discussion:

cc @noamr

yoavweiss commented 1 year ago

One thing to be wary of, and that per-origin quota helps a lot with, is weird dynamics that can be created if the quota is shared between multiple 3P vendors on the page.

mingyc commented 9 months ago

See https://whatpr.org/fetch/1647.html#deferred-fetching:

  1. Let totalScheduledDeferredBytesForOrigin be 0.

...

  1. If totalScheduledDeferredBytesForOrigin is greater than 64 kilobytes, then throw a "QuotaExceededError" DOMException.
mingyc commented 9 months ago

Subsequent request-related discussion in https://github.com/WICG/pending-beacon/issues/87 to avoid confusion