hanford / next-offline

make your Next.js application work offline using service workers via Google's workbox
https://github.com/hanford/next-offline
1.59k stars 113 forks source link

IndexedDb causing Lighthouse error #267

Open marcusfrdk opened 3 years ago

marcusfrdk commented 3 years ago

Hi, I've been trying to get a working NextJS PWA. Everything is working fine at random. Everything except the 'start_url does not respond with a 200 when offline.' works every time. However, at times and when clearing cache it works and results in a full Lighthouse score, but most often not. The applications works perfect offline when reloading and force reloading.

Tested sites

I got the same error on both sites.

Versions and Tested Browsers

MacOS: 10.15.7 Chrome: 87.0.4280.88 (Incognito & Normal) Brave: 1.18.75 (Incognito & Normal) NextJS: 10.0.4 Next-offline: 5.0.3 React: 17.0.1 Node: 15.0.1

Issue

GUESS: IndexedDb/workbox-expiration causes the browser to cache the website, making Lighthouse think that the SW is not working.

Screen Shot 2020-12-24 at 21 12 53

Screen Shot 2020-12-24 at 21 27 37

Screen Shot 2020-12-24 at 21 13 24

Screen Shot 2020-12-24 at 21 15 25

Reproduce

  1. Run Lighthouse with PWA option selected
  2. Everything will either work, or the 'start_url does not respond with 200 when offline' will be marked in red.
  3. Close lighthouse, go into the 'Applications' tab and delete the IndexedDb/workbox-expiration entry and then 'Clear Storage'
  4. Rerun test, and you might get full score.

My manifest.json

...
"start_url": "/",
"scope": "/"
...

Expected

To receive a full Lighthouse score every time.

Actual

Occationally receiving a full Lighthouse score, but more often getting a 'start_url does not respond with a 200 when offlineThe start_url did respond, but not via a service worker.' error in the PWA LH test.

Epilogue

I really love this project, it's super simple to use with NextJS. Thank you for creating it! This might not even be a problem. But I guess Lighthouse should not throw errors when the service worker actually works.

aneenajohn commented 2 years ago

I am having the same issues now. Is there any workaround for this?