log non-network errors in service worker to diagnose #187
This commit is contained in:
parent
9708e394a0
commit
85ba1676e5
1 changed files with 21 additions and 14 deletions
|
@ -86,6 +86,7 @@ function isCacheableThumbnail(url) {
|
|||
|
||||
const baseURL = new URL(self.registration.scope);
|
||||
async function handleRequest(request) {
|
||||
try {
|
||||
const url = new URL(request.url);
|
||||
if (url.origin === baseURL.origin && url.pathname === baseURL.pathname) {
|
||||
request = new Request(new URL("index.html", baseURL.href));
|
||||
|
@ -102,6 +103,12 @@ async function handleRequest(request) {
|
|||
await updateCache(request, response);
|
||||
}
|
||||
return response;
|
||||
} catch (err) {
|
||||
if (!(err instanceof TypeError)) {
|
||||
console.error("error in service worker", err);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
async function updateCache(request, response) {
|
||||
|
|
Reference in a new issue