GoogleChrome / GoogleChrome/workbox

🐛BackgroundSyncPlugin doesn't sync when connection is back

Open
#3,335 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
13k
Forks
880
Avg merge
2h 44m
Merged PRs (30d)
8

Description

**Library Affected**:
workbox-background-sync

**Browser & Platform**:
Chrome Version 125.0.6422.142 (Official Build) (64-bit)

**Issue or Feature Request Description**:
It just doesn't sync when the connection is back. When I reload my page, the event `sync ` doesn't seem listened anymore. After a while the sync is triggered but quite some time after we have the connection back (3 or 4mn maybe).

The implementation is quite basic:
```ts
registerRoute(
({ url }) => isApiUrl(url.href) && url.href.match(/.*\/documents\/.*\//),
new NetworkOnly({
plugins: [
new ApiPlugin({ type: 'update' }), // to update the cache with new data
new BackgroundSyncPlugin('queue-doc-api'), // save when connection is back
],
}),
'PATCH',
);
```

## Demo
[scrnli_6_17_2024_12-47-05 PM.webm](https://github.com/GoogleChrome/workbox/assets/25994652/2873ca20-f515-43e3-bb75-a5c1a220f0c2)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.