From 083998b054b6cc059d54cfcb4cdcc59158239435 Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Wed, 20 Sep 2023 10:31:33 +0200 Subject: [PATCH] Wrap cache query ni a try/catch Signed-off-by: Louis Chemineau --- src/services/PreviewService.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/services/PreviewService.js b/src/services/PreviewService.js index 496fd095b..7a34f92af 100644 --- a/src/services/PreviewService.js +++ b/src/services/PreviewService.js @@ -27,9 +27,14 @@ const SWCacheName = 'images' * Check if the preview is already cached by the service worker * * @param {string} previewUrl - The URL of the preview to check + * @return {Promise} */ export const isCachedPreview = async function(previewUrl) { - const cache = await window.caches?.open(SWCacheName) - const response = await cache?.match(previewUrl) - return response !== undefined + try { + const cache = await window.caches?.open(SWCacheName) + const response = await cache?.match(previewUrl) + return response !== undefined + } catch { + return false + } }