PWA update prompt not working with PouchDB/CouchDB Sync in Vite PWA

149 Views Asked by At

I have a PWA with React using the Vite PWA plugin. Concerning my PWA settings, I have a basic one with a prompt-to-update strategy (https://vite-pwa-org.netlify.app/guide/prompt-for-update.html).

My application integrates PouchDB and CouchDB with live syncing between local and remote databases. Without these database syncs, I correctly receive the prompt to update my application when I make changes to my codebase and rebuild it. However, when I enable the database syncs, I think that the browser don't detect the changes and the prompt no longer appears, so I'm never able to update my application.

Also, I utilize the virtual:pwa-register/react from Vite's virtual module to handle the update prompt.

I've taken several steps to identify the root cause:

Narrowed down the issue to PouchDB and CouchDB syncs: I confirmed that the problem originates from the syncing between PouchDB and CouchDB. When the live sync is disabled, the update prompt functions as expected.

Live sync: The live sync seems to be the disruptor. Without live sync, everything behaves as expected.

Temporary fix: By introducing a pause between each sync initialization, I was able to get the update prompt to work but I feel like this isn't a solid and sustainable solution and it's more of a temporary workaround, I would really like to find the root cause of my issue instead of integrating this solution.

I really expect the update prompt to consistently show up regardless of the database synchronization status, but it seems to conflict with the live sync feature.

Has anyone encountered this issue or have any insights into why this might be happening?

0

There are 0 best solutions below