Background sync in Service Worker is not working in chrome on android
https://web.dev/periodic-background-sync/ indicates that background sync only works from a PWA "installed" and launch as a separate app (rather than as a tab in the browser) - can you clarify whether you attempted to launch it in these conditions?
Background sync of the service worker gets triggered as soon as it has detected the internet connection.
Therefore, anything inside the sync event will also execute (post requests) immediately. Irrespective of stability of the internet connection, So to avoid this I have added a timeout of 3 seconds. now its working as expected.
Sync event listener inside service worker:
self.addEventListener('sync', function (event) {
event.waitUntil(setTimeout(function(){getAllrecordsAndPost()},3000));
});