Disallow sync XHR in page dismissal

Chrome now disallows synchronous XHR during page dismissal when the page is being navigated away from or closed by the user. This involves the following events (when fired on the path of page dismissal): beforeunload, unload, pagehide, and visibilitychange.

Synchronous XHR is on the deprecation path. It hurts the end user experience. beforeunload and unload are used by third parties and first parties to send analytics data to servers. While this is reasonable, there are no good reasons to use synchronous XHR. Instead SendBeacon, Fetch keep-alive should be used (in addition to sending analytics periodically and on pagevisibility etc.). Page dismissal is also an interesting scenario for the following reasons: 1. It hurts the user experience when the user is trying to leave the page or navigate (up to a max timeout of 1s, which is 2s in practice in chrome) 2. The intention of beforeunload handler is a mechanism for preventing data loss for users, however it is used by third parties as a way to reliably do a bunch of work (including sync xhr), up to the max timeout. Some relevant data in this slide deck. This hurts the end user experience. 3. As part of Page Lifecycle API: we want to experiment with running the beforeunload handler at the time of freezing (to determine risk of data loss) to support proactive tab discarding. And Sync XHR (and large amount of work) is problematic here. For now, enterprise users can use the AllowSyncXHRInPageDismissal policy flag to allow synchronous XHR requests during page unload. We expect to remove this flag in Chrome 82.

Status in Chromium

Blink


Behind a flag (tracking bug) in:

  • Chrome for desktop release 78
  • Chrome for Android release 78

Consensus & Standardization

After a feature ships in Chrome, the values listed here are not guaranteed to be up to date.

  • No public signals
  • Public support
  • No public signals
  • No signals

Owner

Intent to Implement url

Intent to Implement thread

Last updated on 2019-09-11