From fd496d7cdd2e29cf9f16043a251cbc759d84770a Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Sun, 20 Oct 2024 12:13:26 -0400 Subject: [PATCH] Wait for promise resolution --- static/serviceworker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/serviceworker.js b/static/serviceworker.js index 38ee813..9b8e84e 100644 --- a/static/serviceworker.js +++ b/static/serviceworker.js @@ -16,7 +16,7 @@ function cacheClients() { includeUncontrolled: true }) .then(allClients => allClients.map(client => client.url)) - .then(pages => [pages, caches.open(cacheName)]) + .then(pages => Promise.all([pages, caches.open(cacheName)])) .then(([pages, cache]) => cache.addAll(pages)) } @@ -33,7 +33,7 @@ function clearInvalidatedCaches() { function trimCache(name, maxItems) { return caches.open(name) - .then(cache => [cache, cache.keys()]) + .then(cache => Promise.all([cache, cache.keys()])) // Make sure offlineFundamentals don't get deleted .then(([cache, keys]) => [cache, keys.filter(key => !offlineFundamentals.includes(key))]) .then(([cache, possibleDelete]) => {