From 8d2e0636d68eb39d9d5358a0d698d96dcc86bc10 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Fri, 24 Aug 2018 08:51:09 -0700 Subject: [PATCH] add null check for index.html fetch in SW (#484) hopefully should fix #483 --- templates/service-worker.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/templates/service-worker.js b/templates/service-worker.js index 8dac4789..f14a97a3 100644 --- a/templates/service-worker.js +++ b/templates/service-worker.js @@ -83,7 +83,10 @@ self.addEventListener('fetch', event => { // for routes, serve the /index.html file from the most recent // assets cache if (routes.find(route => route.pattern.test(url.pathname))) { - return caches.match('/index.html') + let response = await caches.match('/index.html') + if (response) { + return response + } } }