vite-pwa / vite-plugin-pwa

Zero-config PWA for Vite
https://vite-pwa-org.netlify.app/
MIT License
3.12k stars 205 forks source link

React Examples: offlineReady broken in ReloadPrompt #607

Open ColinCee opened 10 months ago

ColinCee commented 10 months ago

So I cloned this repo and ran the react examples. When I go from one route to another its suddenly not offline ready

A couple of questions

See recording

https://github.com/vite-pwa/vite-plugin-pwa/assets/11246116/6a6d0b70-78c6-407f-9ba2-f8860043da3b

userquin commented 10 months ago

offlineReady is a boolean ref activated only once, that's, first time the sw installed: you can use it to show the popup to your users.

If you reload the page when offline it should work, the message is about exactly this, if you go offline before sw finish downloading precache resources, it will fail.

Can you check if there are any error in the console about closing the popup when navigating to another route?

ColinCee commented 10 months ago

Doesn't seem like any error is showing up. This also happens when you reload the home page.

I've encountered this exact same issue with my current app but thought my config was wrong.

Navigated to http://localhost:5173/
ReloadPrompt.tsx:8 {pwaInDevEnvironment: true, webManifest: {…}}
workbox-16108a29.js:45 workbox Precaching 1 file.
ReloadPrompt.tsx:23 Service Worker at: /dev-sw.js?dev-sw
ReloadPrompt.tsx:34 SW Registered: [object ServiceWorkerRegistration]
workbox-16108a29.js:45 workbox The navigation route /about is not being used, since the URL being navigated to doesn't match the allowlist.
Navigated to http://localhost:5173/about
ReloadPrompt.tsx:8 {pwaInDevEnvironment: true, webManifest: {…}}
ReloadPrompt.tsx:23 Service Worker at: /dev-sw.js?dev-sw
ReloadPrompt.tsx:34 SW Registered: [object ServiceWorkerRegistration]
workbox-16108a29.js:45 workbox Router is responding to: /
Navigated to http://localhost:5173/
ReloadPrompt.tsx:8 {pwaInDevEnvironment: true, webManifest: {…}}
ReloadPrompt.tsx:23 Service Worker at: /dev-sw.js?dev-sw
ReloadPrompt.tsx:34 SW Registered: [object ServiceWorkerRegistration]