next-pwa icon indicating copy to clipboard operation
next-pwa copied to clipboard

service worker script returns 404

Open mismosmi opened this issue 2 years ago • 5 comments

Summary

Hi, it seems that something has been broken in the latest release (5.5.5). The necessary files (sw.js etc.) do not get generated in /public anymore.

Versions

  • next-pwa: 5.5.5
  • next: 12.2.2

How To Reproduce

Steps to reproduce the behavior:

  1. Go to this codesandbox
  2. wait for it to start
  3. see the error message

Link to minimal reproduce setup repository if any. https://codesandbox.io/s/bitter-breeze-xcpdqh

Expected Behaviors

sw.js and workbox-[hash].js should be generated in public folder

Screenshots

Screenshot 2022-08-01 at 15 10 37

Additional Context

Might not get noticed until deployed if files are still in the filesystem from before the upgrade.

Best, Michel

mismosmi avatar Aug 01 '22 13:08 mismosmi

We are also suffering this issue - seems to be a breakage in 5.5.5

It seems to be ignoring settings passed in now?

v5.5.5

> [PWA] Compile client (static)
> [PWA] Auto register service worker with: XXXX\node_modules\next-pwa\register.js
> [PWA] Service worker: XXX\src\site\.next\sw.js
> [PWA]   url: /sw.js
> [PWA]   scope: /

v5.5.4:

> [PWA] Compile client (static)
> [PWA] Auto register service worker is disabled, please call following code in componentDidMount callback or useEffect hook
> [PWA]   window.workbox.register()
> [PWA] Service worker: XXXX\src\site\public\sw.js
> [PWA]   url: /sw.js
> [PWA]   scope: /

Config:

    pwa: {
        dest: 'public',
        register: false,
        skipWaiting: false,
        buildExcludes: [/.map$/],
    },

mgoodfellow avatar Aug 01 '22 15:08 mgoodfellow

Having the same issue after updating to 5.5.5. After rollback to previous version it was fine again. The sw.js and workbox file weren't generated into /public (dest) anymore.

I noticed that bug after the PWA wasn't updating itself on android chrome anymore since service worker was 404.

should be in /public instead of /.next:

> [PWA] Service worker: /Users/workspace/mono/app-client/.next/sw.js
> [PWA]   url: /sw.js

adrianstanek avatar Aug 02 '22 22:08 adrianstanek

Also, if I write SW in options to look for different serviceWorker.js files in the public folder, it's not looking for the same.

ashish1497 avatar Aug 03 '22 05:08 ashish1497

#372 may resolve this problem.

Lukasdotcom avatar Aug 03 '22 19:08 Lukasdotcom

I am experiencing the same issue

shestakov-vladyslav avatar Aug 06 '22 20:08 shestakov-vladyslav

How do i solve this for now?

tusqasi avatar Aug 07 '22 16:08 tusqasi

The best fix is downgrading to version 5.5.4

Lukasdotcom avatar Aug 07 '22 16:08 Lukasdotcom

ok, thanks

tusqasi avatar Aug 07 '22 17:08 tusqasi

This PR is related to the issue, https://github.com/shadowwalker/next-pwa/pull/368

felixmosh avatar Aug 08 '22 12:08 felixmosh

@Lukasdotcom any tip is appreciated.

The best fix is downgrading to version 5.5.4

What is the compatible next version and pwa config in next.config.js that works with [email protected]? Locally I am able to run it fine (Lighthouse checkmark, PWA is correctly set) with [email protected] and this config:

  pwa: {
    dest: 'public',
    // register: true,
    // skipWaiting: true,
    runtimeCaching,
    buildExcludes: [/middleware-manifest.json$/],
  },

However, when deployed to Vercel on production, Lighthouse shows there's no service worker: Does not register a service worker that controls page and start_url

I've tried messing up with the config based on several issues of this repo, none of them seems to work in production.

f4z3k4s avatar Aug 08 '22 16:08 f4z3k4s