Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

service worker script returns 404 #378

Closed
mismosmi opened this issue Aug 1, 2022 · 10 comments · Fixed by #372
Closed

service worker script returns 404 #378

mismosmi opened this issue Aug 1, 2022 · 10 comments · Fixed by #372
Labels
bug Something isn't working

Comments

@mismosmi
Copy link

mismosmi commented Aug 1, 2022

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 mismosmi added the bug Something isn't working label Aug 1, 2022
@mgoodfellow
Copy link

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$/],
    },

@adrianstanek
Copy link

adrianstanek commented Aug 2, 2022

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

@ashish1497
Copy link

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.

@Lukasdotcom
Copy link
Contributor

#372 may resolve this problem.

@shestakov-vladyslav
Copy link

I am experiencing the same issue

@tusqasi
Copy link

tusqasi commented Aug 7, 2022

How do i solve this for now?

@Lukasdotcom
Copy link
Contributor

The best fix is downgrading to version 5.5.4

@tusqasi
Copy link

tusqasi commented Aug 7, 2022

ok, thanks

@felixmosh
Copy link
Contributor

This PR is related to the issue, #368

@f4z3k4s
Copy link

f4z3k4s commented Aug 8, 2022

@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 next-pwa@5.5.4? Locally I am able to run it fine (Lighthouse checkmark, PWA is correctly set) with next@12.1.6 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants