-
-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Background sync does not work #739
Comments
Try replacing You can also add internal plugins to the handlers, check sveltekit linked comment issue. |
I just realized Firefox does not support this API at all |
can you share the repo if public? |
I haven't yet gotten background sync to work either, but I do know that you should be getting errors because you have multiple configurations that use the same name. If you need to apply the background sync to multiple methods, I think you have make I'm about to try userquin's advice and I'll report back here. |
I'm unable to get anything at all w/r/t background sync. I'm stopping my dev server(s) and have even tried turning off my WiFi. Typically I create an entity using a POST command. Then I turn off my dev server/wifi and issue the DELETE command from the app. Nothing turns up in DevTools under IndexedDB or Background sync. Here's my Vite PWA configuration:
|
After searching and tinkering, I came across this github issue: GoogleChrome/workbox#2393 My tests indicate that this is pivotal bit to get background sync working, at least when running things from the Vite dev server. If they are trying to test this feature using the dev server, my recommendation for @VityaSchel then, is to simply add For example
|
My goal is to have PWA that can work offline and online with Vite. I've added vite-plugin-pwa and configured background sync as follows:
Now when I make fetch request to my server when offline I expect it to immediately reject with some kind of error and add to that indexeddb queue with name 'api-queue' and automatically retry when browser is online within period of 72 hours
This is my wrapper function for making api request:
Which should either throw error (if user is online, for example if api is down) or show 'Changes will be synced when you come back online' toast when user is offline indicating that service worker added request to queue
However most of the times the request is simply stuck in network tab until it timeouts in like 1 minute, and promise never neither rejects nor fulfills. Other tiems it just instantly rejects with some error like NS_ERROR_UNKNOWN_HOST and correctly shows toast about pending changes. However after I connect to internet again, no requests to network are made in network tab.
More importantly, in neither of these cases, nothing is added to indexeddb workbox-background-sync which should hold requests until they fulfilled
os: macos 14.5
browser: firefox 129.0
The text was updated successfully, but these errors were encountered: