#776: Early Design Review: Pending Beacon API
Discussions
Discussed
Oct 1, 2022 (See Github)
bump to plenary
Discussed
Oct 1, 2022 (See Github)
punt to next week
Discussed
Nov 1, 2022 (See Github)
bumped
Comment by @mingyc Dec 8, 2022 (See Github)
Friendly ping on this request as it has been a while.
Comment by @ylafon Feb 7, 2023 (See Github)
Hi, @maxpassion and I reviewed this during our F2F and we have a few questions:
About the use of Get/PostPendingBeacon, why not using the method in a dictionary instead of having two instances? How about ensuring that a PostPB isn't sent twice (like if there is a crash). Issues about crash recovery, should it be done after a network and/or location change, as it can have privacy implications? after a time limit? Do having a pending beacon registered impact how bfcache work?
What is the point of forcing a PendingBeacon to be sent, if it is supposed to be sent at the end of the interaction, why not using fetch or a normal beacon in that case?
Why existing mechanism is not reliable and how this new proposed mechnisam solve the not reliable issue? Should the HTML unload event be fixed instead? Could this be solved at the Page Lifecycle level instead of having a new specification?
Thanks,
Comment by @mingyc Feb 16, 2023 (See Github)
About the use of Get/PostPendingBeacon, why not using the method in a dictionary instead of having two instances?
The proposal to have two different classes PendingGetBeacon
& PendingPostBeacon
is to help enforcing type safety. There was an explanation https://github.com/WICG/pending-beacon/issues/59#issuecomment-1325977557.
How about ensuring that a PostPB isn't sent twice (like if there is a crash).
A browser should ensure that a queued PendingBeacon can only be sent once. At the time of crashing, browser should know that whether a given PendingBeacon is sent or not. But it cannot guarantee the "send" action succeed. => This behavior needs to be addressed by maybe a retry mechanism.
Issues about crash recovery, should it be done after a network and/or location change, as it can have privacy implications? after a time limit?
Crash recovery is still under discussion. But we think that network status after a crash does not matter, as developers can already achieve similar effect using local DB, e.g. storing data manually and recover from indexDB after a crash.
Do having a pending beacon registered impact how bfcache work?
Nope. One of the goals of this proposal is to provide a reliable API that developers can use along with bfcache.
What is the point of forcing a PendingBeacon to be sent, if it is supposed to be sent at the end of the interaction, why not using fetch or a normal beacon in that case? Why existing mechanism is not reliable and how this new proposed mechnisam solve the not reliable issue?
Please see this section discussing about an alternative approach Extending Fetch API and this comment arguing that the goal of this proposal is beyond the scope of fetch() API.
Should the HTML unload event be fixed instead? Could this be solved at the Page Lifecycle level instead of having a new specification?
We don't think so. This section from the explainer describes that the page lifecycle events are not sufficient.
Please let us know if you have any other questions. Thanks for your time!
Discussed
Mar 1, 2023 (See Github)
Tess: looks like Yves had questions and they were answered...
Yves: ...
Tess: linked moz and webkit standards positions.. some interesting discussion. There is already a "beacon" spec - this is different. It's on purpose. But seems unfortunate that you have 2 similar sounding things with similar purposes. Feels like we should try to merge these things or find a way to integrate them.
Dan: that sounds architectural.
Tess: beyond that ... the basic issue
Dan: no user needs...
Tess: sites want to reliably know if something bad happened. But if something sufficiently bad happens then site can't reliably know. E.g. device crashes; browser crashes. There is a tension bwteen having a reliable signal and the reality of software in the wild.
Dan: state and the web being stateless...
Yves: you have local state with cookies -- local storage... so this is not about giving state.
Dan: can we push back and ask for some user needs?
Tess: right now the explainer only has dev needs - you can infer user needs. But I'd rather them to be explicit.
Peter: also there should be a user benefit aside from analytics and tracking.
Dan: leaves comment on user needs
Tess: will read the discussions and follow up.
Discussed
Mar 1, 2023 (See Github)
Tess: Some feedback I've heard: insufficient integratoion with sendbeacon... Entirely new API that is in similar space to existing APIs... and maybe a better API shape would have been to add an argument to an existing API? Webkit's position -
Dan: Support but with concerns.
Yves: supposedly it's to save a state server side from the client. The fact that it can be done using GET is not really nice. Should be a post. Using a get is not ideal. will leave comment
Tess: Agree. I can leave a comment.
Comment by @hober Mar 13, 2023 (See Github)
Comment by @torgo Mar 13, 2023 (See Github)
One thing we noticed in reviewing the explainer is a lack of user needs. Could you spend a few minutes writing at the beginning how this benefits the user? This is part of our explainer explainer and is intended to get people thinking in terms of user benefit. Thanks! https://tag.w3.org/explainers/
Discussed
Apr 1, 2023 (See Github)
Yves noted that they're using HTTP GET inapproriately. It also looks like they're working on a very big change to this, so perhaps we should defer reviewing it until that happens.
Comment by @ylafon Apr 3, 2023 (See Github)
Looking again at the spec, the goal is to send data/state to a server using HTTP POST... and also GET?
Comment by @mingyc Apr 3, 2023 (See Github)
One thing we noticed in reviewing the explainer is a lack of user needs.
Our goal is to provide web developers with a reliable ‘beaconing’ API.
Looking again at the spec, the goal is to send data/state to a server using HTTP POST... and also GET?
Yes, as stated in the Motivation section, more accurately it is sending a bundle of data to a backend server, without expecting a particular response, ideally at the ‘end’ of a user’s visit to a page.
Comment by @miketaylr Apr 3, 2023 (See Github)
It's a bit hard to be sure, but after reading https://github.com/WICG/pending-beacon/blob/main/README.md#open-discussions and beyond, it seems that sending data/state is only supported for POST, and not GET. Is that correct?
Comment by @mingyc Apr 4, 2023 (See Github)
Ah sorry nope. Our initial intention is to support both POST & GET. But some ongoing discussions in https://github.com/WICG/pending-beacon/issues/72 suggests us to support a general fetch() request, which includes other HTTP methods.
Comment by @hober Apr 20, 2023 (See Github)
It seems like some major changes are in the works (see https://github.com/WICG/pending-beacon/issues/70 and related issues) so I'm not sure if there's much value in us reviewing what will likely soon drastically change.
Comment by @fergald Apr 20, 2023 (See Github)
The changes are all in the API (completely new API vs integrating with fetch). I think the behaviour and goals are unchanged and it would be helpful to review those if you have time.
Comment by @hober Apr 27, 2023 (See Github)
Comment by @npdoty Apr 27, 2023 (See Github)
Just a +1 for including some explanation of how or why this would benefit users.
It seems like the implicit reasoning here (as with previous Beacon APIs) is that websites want to send potentially large amounts of data particularly when a user navigates away from a page. Doing this in the background perhaps makes current abusive behavior (attempts to block navigation altogether until the data is sent) less annoying. But as a side effect, it means that the network traffic happens when the user is doing something else. The page that collected and sent the traffic is more opaque to the user, and any slowdowns that happen won't be attributed back to the page causing them, so more pages may feel comfortable collecting and sending more data.
Comment by @fergald Apr 28, 2023 (See Github)
@npdoty
Just a +1 for including some explanation of how or why this would benefit users.
It seems like the implicit reasoning here (as with previous Beacon APIs) is that websites want to send potentially large amounts of data particularly when a user navigates away from a page. Doing this in the background perhaps makes current abusive behavior (attempts to block navigation altogether until the data is sent) less annoying. But as a side effect, it means that the network traffic happens when the user is doing something else. The page that collected and sent the traffic is more opaque to the user, and any slowdowns that happen won't be attributed back to the page causing them, so more pages may feel comfortable collecting and sending more data.
The criticisms apply to keep-alive
fetch and somewhat to sendBeacon
.
sendBeacon
is explicltly specced not to contend for network or CPU with the next page-load, pending beacon should do something similar, although I don't think we have called that out in the explainer. It is also allowed to delay sending while the page is visible, to save network/battery.
They both impose a quota on how much data there can be outstanding. The quota is shared with the pending beacons too. Discussion is still ongoing on how exactly to make that work but this should be a neutral change in that regard.
keep-alive
fetch is eager when called with the request starting immediately.
keep-alive
fetch must read the entire response. We don't expect beacon responses to be large (since they cannot be accessed from JS) but if they are, there may be an occasional win there in not reading them.
Pending beacon allows updating the payload (most likely cancel and replace) this means they will send less data overall than sendBeacon
.
Also, vs keep-alive
fetch, knowing that the request is a beacon, not requiring a response means that browsers have flexibility on how/when to send these. I think we'd want to see it being a real problem before trying any of these but browsers could delay sending beacons for a few seconds if another page has just started loading or just send them rate-limited. I would expect that responses will be minimal since they cannot be accessed from JS but there may also be something to be gained not reading responses past the headers and closing the connection when the payload is confirmed accepted. The same argument is a positive for sendBeacon
.
We should add this to the explainer. @mingyc
Discussed
Jul 1, 2023 (See Github)
Tess: ...linked to the agreement that we came to on their issue 70 ... there's actually a PR on the fetch spec... I thought we should close it. Fergal said the changes are in the API...
triaged
Discussed
Jul 1, 2023 (See Github)
Sangwhan to post asking them to close, design has changed.
Comment by @hober Jul 17, 2023 (See Github)
Comment by @cynthia Jul 31, 2023 (See Github)
We're assuming deferred fetch as proposed in https://github.com/whatwg/fetch/pull/1647 will supersede this, should this be closed? @mingyc @fergald
Comment by @mingyc Aug 3, 2023 (See Github)
In that case, should deferred fetch be reviewed here (or in another new issue)?
Comment by @cynthia Aug 5, 2023 (See Github)
For this case I might recommend a new issue.
Comment by @mingyc Aug 28, 2023 (See Github)
Filed a Specification Review https://github.com/w3ctag/design-reviews/issues/887 as I think we have passed the early design stage.
Discussed
Jan 1, 2024 (See Github)
closed
Comment by @martinthomson Jan 23, 2024 (See Github)
See #887 for the review of FetchLater, which is the successor of this.
OpenedSep 27, 2022
Wotcher TAG!
I'm requesting a TAG review of Pending API.
This is a proposal for Pending Beacon API. It is a system for sending beacons when pages are discarded, that uses a stateful API rather than having developers explicitly send beacons themselves.
Further details:
You should also know that...
[please tell us anything you think is relevant to this review]
We'd prefer the TAG provide feedback as (please delete all but the desired option):
💬 leave review feedback as a comment in this issue and @-notify @mingyc and @fergald