Fail closed when worker update status is unavailable

This commit is contained in:
Jonathan Sykes
2026-10-08 00:10:04 +08:00
parent 5d1e5ec791
commit 92404563b3
2 changed files with 9 additions and 0 deletions

View File

@@ -161,6 +161,9 @@
const reg = root.navigator && await root.navigator.serviceWorker.getRegistration();
const worker = reg && (reg.waiting || reg.active);
const status = await askCacheStatus(worker);
// Unknown protocol is a retryable failure, never an empty successful
// legacy refresh followed by a reload into the old persistent manifest.
if (worker && !status) throw new Error('Worker update status unavailable; try again');
if (status && status.assetSync) {
const result = await core.syncAssets(m,{cache,fetchFn:opts.fetchFn});
if (!reg.waiting) await core.commit(m,cache);