GenerateSW has been called multiple times

See original GitHub issue

Hello, I recently setup next-pwa on by next.js app, and when using running in development next dev, every new page load (for that development session) will see GenerateSW being called again. This ends up being annoying as it causes lag on page navigation, is disruptive in the console, and causes a new sw.js to be generated all the time, even though no changes have been made (I don’t even have a custom serviceworker setup right now at all.

On the live app (Hosted & compiled by vercel/ZEIT), no GenerateSW error appears in the console. I’m running next.js ^9.3.3 and next-pwa ^2.4.0.

The error message reads: [ warn ] GenerateSW has been called multiple times, perhaps due to running webpack in --watch mode. The precache manifest generated after the first call may be inaccurate! Please see https://github.com/GoogleChrome/workbox/issues/1790 for more information.

Since I’m totally brand new to serviceworkers and PWA in general, I have no idea how to get around this issue.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
paalescommented, May 10, 2020

In your config you can do something like this to disable the generation in development mode:

      pwa: {
        disable: process.env.NODE_ENV !== 'production',
      }

Maybe that would be a good default, for the module, or is it advised to run with a service worker in development?

3reactions
shadowwalkercommented, Jun 2, 2020

Hi @adammesa it has nothing to do with the dependency. When you run yarn dev, it run next command in dev mode, which is using the webpack watch mode. Yes, sw.js do get generated repeatedly if pwa is not disabled. The reason behind that is sometimes people want to debug certain features in dev mode (such as web push). You can simply put disable: process.env.NODE_ENV !== 'production' to your pwa configuration to disable it in dev mode. Remember clear all cache data and reload first when you couldn’t figure out the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GenerateSW has been called multiple times · Issue #7272 ...
GenerateSW has been called multiple times, perhaps due to running webpack in --watch mode. The precache manifest generated after the first ...
Read more >
Next.js App reloads frequently in production - Stack Overflow
GenerateSW has been called multiple times, perhaps due to running webpack in --watch mode. The precache manifest generated after the first ...
Read more >
Hot Module Reload for PWA - Quasar Framework
GenerateSW has been called multiple times, perhaps due to running webpack in --watch mode. The precache manifest generated after the first call may...
Read more >
workbox-webpack-plugin - Chrome Developers
GenerateSW. This class supports creating a new, ready-to-use service worker file as part of the webpack compilation process. Use an instance of GenerateSW...
Read more >
PWA - hot reload causing errors - Quasar forum
GenerateSW has been called multiple times, perhaps due to running webpack in --watch mode. The precache manifest generated after the first ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found