From ac09f76523424b140f498653c2109741b6d18f52 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 23 May 2025 15:26:36 +0900 Subject: [PATCH] Delay background sync while prerendering Closes #354. The only relevant background sync API accessible from Windows is serviceWorkerRegistration.sync.register(). This registers a sync to happen later when the user is online. At first I thought allowing this to happen while prerendering might be OK. However, the method explicitly throws an exception if it's used when there are no top-level/auxiliary clients. https://developer.chrome.com/blog/background-sync/ seems to imply this is an abuse prevention measure: "You can only register for a sync event when the user has a window open to the site." So, we decide to delay any background sync registrations while prerendering. --- prerendering.bs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/prerendering.bs b/prerendering.bs index f1a4c9a..52db8d6 100644 --- a/prerendering.bs +++ b/prerendering.bs @@ -945,6 +945,10 @@ Add {{[DelayWhilePrerendering]}} to {{PushManager/subscribe()}}. Add {{[DelayWhilePrerendering]}} to {{BackgroundFetchManager/fetch()}}. +

Background Sync

+ +Add {{[DelayWhilePrerendering]}} to {{SyncManager/register()}}. +

Storage API

Add {{[DelayWhilePrerendering]}} to {{StorageManager/persist()}}.