pwa-builder / PWABuilder

The simplest way to create progressive web apps across platforms and devices. Start here. This repo is home to several projects in the PWABuilder family of tools.
https://docs.pwabuilder.com
Other
2.54k stars 273 forks source link

[BUG] PWABuilder Report Card is not recognizing the service worker running (site: https://pwhl-remix.vercel.app/) #4674

Closed smoak closed 4 months ago

smoak commented 4 months ago

What happened?

I ran the report card, but it says "PWABuilder has analyzed your site and did not find a Service Worker."

However, there is a service worker registered. Chrome Dev Tools and Firefox Dev Tools show a service worker running and activated.

Chrome dev tools:

2024-03-03_12-31

Firefox dev tools:

2024-03-03_12-32

How do we reproduce the behavior?

  1. Go to https://www.pwabuilder.com/reportcard?site=https://pwhl-remix.vercel.app/
  2. Scroll down to the Service Worker Section

What do you expect to happen?

For the service worker to be detected.

What environment were you using?

OS: Linux Kernel: 6.6.18-1-lts x86_64 Browser: chromium 122.0.6261.69 AND firefox 123.0 Device: ThinkPad X1 Yoga 3rd Gen CPU: quad core Intel Core i7-8650U

Additional context

No response

Jaylyn-Barbee commented 4 months ago

On first load of your site, I don't see a service worker registered. It isn't until I refresh that your service worker loads and is activated. Since it is a bot looking for your SW and it's not loading on the first pass, this could be why your SW isn't being detected.

image

Update: I have been playing with this for a few more minutes and the behavior is a bit different across browsers and even in incognito. Going to get some more people on the team to mess around with this to double check.

khmyznikov commented 4 months ago

@smoak @Jaylyn-Barbee getting same behaviour in Edge and Kiwi Mobile. After 5-6 refreshes I have finally got the SW in Edge. Clean website data and check your app logic. In Chrome I can't reproduce this... Try to not use windows load event at all in sw registration. image Update: yeah, it's definitely a problem in this event. It's triggers before this code and never executes. image

jgw96 commented 4 months ago

As this is an issue in yalls service worker, I am going to close this issue for now, but please feel free to open a new issue if you make our suggested changes and still hit issues. Thanks for using PWABuilder!

smoak commented 4 months ago

Try to not use windows load event at all in sw registration.

@khmyznikov Can you help me understand why I shouldn't use this? The workbox docs suggests waiting until the page is fully loaded before registering the service worker

2024-03-07_13-54

Further documentation suggests this as well:

If a service worker precaches anything, then the time at which it's registered matters. Service workers are often registered using inline Githubissues.

  • Githubissues is a development platform for aggregating issues.