Questions tagged [background-sync]
61 questions
4
votes
2 answers
Service Workers: when does the browser sync back again?
I am building a progressive web application using Google Workbox. I have setup a service worker with bgSync (in my build folder) so that my POST requests are pushed to a queue and sent to my endpoint when the user regains connection, but when does…

andrralv
- 810
- 7
- 18
4
votes
0 answers
How to handle AJAX response with service worker (Workbox) when connection is restored
I'm building a PWA using the Vue CLI 3 PWA plugin, and I'm not sure how to handle the response from an AJAX call made while offline.
All I have is basically sample code from the Workbox documentation...
// service-worker.js
const queue = new…

jreed121
- 2,067
- 4
- 34
- 57
4
votes
1 answer
How to avoid conflict between "dom" and "webworker" libs?
I am using TypeScript with React, and one of the things I want to achieve is background sync for offline support.
To enable typings for service worker, I have to include the WebWorker lib, but it conflicts with DOM lib and produces an error:
(25,1):…

Shunxu Huang
- 71
- 4
4
votes
4 answers
Auto refresh a page in React.js
I need to continuously update/refresh my page to ensure that it is in sync with my server. Currently, I am using setInterval, but I read that serviceWorkers might solve my problem in a better way. Is it recommended to use serviceWorkers? (the…

raksheetbhat
- 850
- 2
- 11
- 25
3
votes
0 answers
Alternative for service-worker (background request) in iOS WKWebView < 14
Since Service-workers are not supported in WkWebView in iOS < 14,
Sources:
http://openradar.appspot.com/51092505
https://webkit.org/blog/8090/workers-at-your-service/
Service workers unavailable in WKWebView
is there any alternative to implement…

Xxx
- 31
- 2
3
votes
0 answers
Workbox Background Sync CORS
I'm using Workbox using the background sync plugin. Unfortunately the plugin did not run as expected for my application, which relies on a CORS request.
My app first sends an options preflight request to ensure that the request is allowed, and then…

ricardo gunawan
- 31
- 4
3
votes
1 answer
JavaScript Background Sync Stops Working if Page is Loaded/Refreshed while offline
I'm currently learning how to use Background Sync as to allow users to PUT/POST changes while using a web app offline.
I followed the instructions given by Jake Archibald in
Introducing Background Sync , and everything worked great... as long as I…

Alexandro Perez
- 61
- 4
3
votes
1 answer
React PWA with workbox PWA
I am doing research on PWA from last one week I found that Workbox is good option to implement and I tried to implement the PWA using React+worbox+webpack I am able to create App icon, caching of GET apis data but not able to cache server side user…

kusum.ratawa
- 31
- 3
3
votes
0 answers
serviceWorker.ready never resolves unless within setTimeout
In a page's domready event I'm setting an event listener for a button that sets a Background Sync event in a page on my website (when offline), but even if the service worker has been loaded already on previous page visits, this line of code never…

Squrl G
- 31
- 4
3
votes
1 answer
Best practice pattern for service worker background-sync with CSRF protection
I have a request that uses a one time token embedded in the page to ensure CSRF protection - an attacker might be able to fool my users into making a illicit request, but they can't get the token, and even if they can it is changed with each request…

Keith
- 150,284
- 78
- 298
- 434
2
votes
1 answer
How to fix "unable to resolve host" error in WorkerWrapper?
I'm trying to implement background sync on Android.
It works just fine when emulator (API 30) is awake and unlocked.
But if I quit the app (not force quit, just remove from the recent apps) and lock the emulator screen - eventually I'll start…

Maxim Mazurok
- 3,856
- 2
- 22
- 37
2
votes
1 answer
Workbox background sync doesn't run if setting onSync callback
In my service worker, I'm implementing background sync with workbox like so
workbox.routing.registerRoute(
options => options.url.pathname.startsWith('/api/'),
new workbox.strategies.NetworkOnly({
plugins: [
new…

Kirill Rakhman
- 42,195
- 18
- 124
- 148
2
votes
0 answers
No background sync after restarting browser
I am implementing PWA with a service worker, utilizing Background Sync and IndexedDB in uploading images while user is offline.
So it is working! While offline on uploading an image, nativeFile is pushed to IndexedDB and a unique tag is registered…

Emmanuel Sayson
- 279
- 3
- 14
2
votes
2 answers
Workbox is caching only time stamps to indexDb, how to intercept with json data in indexDb?
Below route defines to store json data as MyCachedData in cache storage, and IndexDb only stores the url and timestamp.
workboxSW.router.registerRoute('/MyApi(.*)',
workboxSW.strategies.staleWhileRevalidate({
cacheName: 'MyCachedData',
…

seUser
- 1,093
- 2
- 10
- 21
2
votes
1 answer
Service Worker Background Sync - On rejecting promise - there are no retries from the waitUntil?
I am creating a offline first blogging platform which utilises IndexedDB and service workers. The idea here is if the user is offline and trying to send a post - send it in the background. This project is for my dissertation, I have only been…

George Cook
- 306
- 3
- 12