From 40b472ce9d3d74571ab9134aff1af859661ed3bd Mon Sep 17 00:00:00 2001 From: userquin Date: Thu, 2 Nov 2023 13:34:29 +0100 Subject: [PATCH] chore: add custom plugin to log errors --- service-worker/sw.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/service-worker/sw.ts b/service-worker/sw.ts index 94c6e54d..e11aee93 100644 --- a/service-worker/sw.ts +++ b/service-worker/sw.ts @@ -63,6 +63,19 @@ if (import.meta.env.PROD) { ignoreVary: true, }, plugins: [ + { + fetchDidFail: async ({ error, request }) => { + console.error('webmanifest fetchDidFail', error, request.url) + }, + handlerDidError: async ({ error, request }) => { + console.error('webmanifest handlerDidError', error, request.url) + return undefined + }, + cacheWillUpdate: async ({ request, response }) => { + console.error('webmanifest cacheWillUpdate', request.url) + return response?.status === 200 ? response : null + }, + }, new CacheableResponsePlugin({ statuses: [200] }), // we only need a few entries new ExpirationPlugin({ maxEntries: 100 }),