WICG / pending-beacon

A better beaconing API
Other
43 stars 9 forks source link

`setData(data)` and request payload limit #21

Closed mingyc closed 11 months ago

mingyc commented 2 years ago

It's not mentioned in current explainer, but I assume browser should impose a limit for request payload similar to navigator.sendBeacon()'s one?

navigator.sendBeacon() returns false if the amount of data to be queued exceeds the user agent limit. It's partly because the underlying implementation is using Fetch API, where there is a discussion about payload limits in https://github.com/w3c/beacon/pull/39. But for PendingBeacon, it's not specified to to use Fetch.

Should setData(data) throw exception or return false? (Whether to throw exception from PendingBeacon API is also not specified yet)

mingyc commented 11 months ago

Request payload limit is addressed in https://github.com/WICG/pending-beacon/issues/76#issuecomment-1807713924 and https://github.com/WICG/pending-beacon/issues/66

setData(data) now longer exists in fetchLater(), which supports request body via its RequestInfo or DeferredRequestInit args, e.g.

fetchLater(url, {
  body: ...
});

After calling the API, the request is not updatable. Developers will have to abort previous pending fetchLater requests first. See also Update a pending request.