From c43cf33c95f79b3efae620cda42cedaa5fd8eba5 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 4 Nov 2020 00:13:45 +0100 Subject: [PATCH] fast claim all clients --- packages/nitro/src/targets/sw/entry.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/nitro/src/targets/sw/entry.ts b/packages/nitro/src/targets/sw/entry.ts index ffa520a9ea..e02d78428f 100644 --- a/packages/nitro/src/targets/sw/entry.ts +++ b/packages/nitro/src/targets/sw/entry.ts @@ -11,6 +11,16 @@ addEventListener('fetch', (event: any) => { event.respondWith(handleEvent(url, event.request)) }) +self.addEventListener('install', () => { + // @ts-ignore + self.skipWaiting() +}) + +self.addEventListener('activate', (event) => { + // @ts-ignore + event.waitUntil(self.clients.claim()) +}) + async function handleEvent (url, request) { try { const { html, status, headers } = await render(url.pathname, { req: request })