GenerateSW has been called multiple times
See original GitHub issueHello,
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:
- Created 3 years ago
- Comments:9 (1 by maintainers)
Top Related StackOverflow Question
In your config you can do something like this to disable the generation in development mode:
Maybe that would be a good default, for the module, or is it advised to run with a service worker in development?
Hi @adammesa it has nothing to do with the dependency. When you run
yarn dev, it runnextcommand in dev mode, which is using the webpack watch mode. Yes,sw.jsdo 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 putdisable: process.env.NODE_ENV !== 'production'to yourpwaconfiguration to disable it in dev mode. Remember clear all cache data and reload first when you couldn’t figure out the issue.