Retry transient foreground requests before surfacing errors
This commit is contained in:
@@ -264,7 +264,8 @@ self.addEventListener('fetch', (e) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ASSET_SYNC && request.mode === 'navigate') e.waitUntil(completeAssets());
|
||||
// The page schedules completion after first paint/idle via Lazy.warm(). Do
|
||||
// not start a six-file background burst from this foreground fetch event.
|
||||
|
||||
// Only intercept GET/HEAD — let POST (sync endpoint) go through unmodified
|
||||
if (request.method !== 'GET' && request.method !== 'HEAD') return;
|
||||
@@ -573,8 +574,8 @@ async function activateAssets() {
|
||||
for (const req of await cache.keys()) if(new URL(req.url).pathname.startsWith('/__ytp_candidate/')) await cache.delete(req);
|
||||
await self.clients.claim();
|
||||
if(old && old.current.buildTag !== m.buildTag) for(const c of await self.clients.matchAll({type:'window',includeUncontrolled:true})) c.postMessage({type:'SW_UPDATE_AVAILABLE',version:VERSION});
|
||||
// Completion owns a message-event lifetime, not the activation barrier.
|
||||
// In particular, a legacy client's four-second reload must not wait for it.
|
||||
// Resume completion after activation, but with one request at a time so
|
||||
// foreground navigation retains most of the available bandwidth.
|
||||
self.registration.active.postMessage({ type: 'COMPLETE_ASSETS' });
|
||||
try { console.info('[asset-sync] storage', await self.navigator.storage.estimate()); } catch {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user