-
Notifications
You must be signed in to change notification settings - Fork 822
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
v3 bgSync replayRequests unsupported #1248
Comments
@philipwalton should we just expose |
I don't think so. The reason we originally changed the It sounds to me like @DavidScales should be using the |
Thanks for the replies. @philipwalton can I request documentation updates then? I'm not sure how to go about doing that with the current v3 backgroundSync guide or modules documention. To me the documentation suggests that the const queue = new workbox.backgroundSync.Queue('myQueueName');
const request = new Request('/path/to/api', {
method: 'POST',
body: someformData,
});
try {
await fetch(request);
} catch (err) {
queue.addRequest(request);
} seems like what I would want to do if I just want to create a queue for requests I'm constructing manually in my main thread (perhaps I'm not even using service workers). While the
and the fact that it flows with my other SW code & works almost completely (only I could be misunderstanding something. I'm not super familiar with what separates a |
I didn't meant to push this to master, but to bring bg sync docs in line with the rest of the module. Changes are here: google/WebFundamentals@112812d @DavidScales does that kind of solve the doc issue or is there more? @philipwalton is this ok with you? |
@gauntface sorry but I still don't see why my original posted code shouldn't work, based on the updated documentation. And I don't see why I would use the Queue class directly like @philipwalton is suggesting, nor how I would do so to implement my desired behavior 😕 The Using Workbox Background Sync with other Workbox Packages example still seems like exactly what I'm looking for, and works as described, except for |
Your original code works for me: https://quixotic-quit.glitch.me/ |
An
error causes the sw registration to fail
But yeah my code above works - what doesn't work is then calling |
That API doesn't exist on the plugin: https://developers.google.com/web/tools/workbox/reference-docs/prerelease/workbox.backgroundSync.Plugin The class Queue itself has that method: https://developers.google.com/web/tools/workbox/reference-docs/prerelease/workbox.backgroundSync.Queue |
I think I fixed the demo, but Chrome is showing:
and Firefox doesn't support Sync but will show notification intermittently. |
Yeah, for sure. To re-iterate/summarize, I know that
Given that, my questions are:
If I'm just out in left field and not making any sense, I'm always open to hearing that as well 😉 |
@DavidScales Can you open a bug with code example on the Queue stuff and keep this issue focused on the Plugin stuff. I'm just getting pretty lost with the amount of code going around in this issue and what is the actual problem. Why not expose |
okay I've created an issue for getting |
@DavidScales I think the plugin is what you want - you just want a way to Force a sync event - i.e. work with DevTools. I'll dig into what you can use for the code lab - but adding the API isn't the way forward IMO. |
Ok so it looks like you can just use the sync button in Chrome DevTools to force everything to kick off - I didn't have to set a tag or anything. So flow was
|
@DavidScales I've added a section to the bottom of the background sync stuff: https://developers.google.com/web/tools/workbox/modules/workbox-background-sync Is this enough to do what you want? |
@gauntface the documentation change is very helpful thanks! 👍 And I'm convinced of switching over to DevTools like you've suggested. From my standpoint we can close this issue, everything unresolved is alive in #1266 However, (this possibly warrants a separate issue?) I'm not able to run the
Possibly a Firebase permissions thing? |
@DavidScales thats because the joy that is Firebase hosting + functions requires you to be logged in and have access to the project - regardless of local testing or actually deploying :( I'm going to close this issue now if everything seems patched up in docs. |
ah ok. SGTM. thanks again! |
Library Affected:
workbox-backgroundSync
Browser & Platform:
Google Chrome v63.0.3
I'm trying to set up background sync with Workbox v3. After #1222, I have basic functionality, and I've added the
queueDidReplay
callback to show a notification when bg sync occurs:This currently works, but bg sync takes about 5 minutes to happen in Chrome, and I'd like to replay the queued requests immediately. To achieve this I tried calling
But this doesn't appear to work, as
replayRequests
is not a method ofbackgroundSync.Plugin
:So I changed
backgroundSync.Plugin
tobackgroundsync.Queue
, and that allows me to callreplayRequests
. But after switching tobackgroundsync.Queue
, failed requests are no longer being queued, and I'm not getting any console errors to indicate what's going wrong.I understand that I might not be able to just swap
Plugin
&Queue
interchangably, but if usingQueue
is not that solution, then how would I implement this functionality withPlugin
? IfQueue
is the answer, what am I doing wrong?Separate but related issues:
#1247 & #1249
The text was updated successfully, but these errors were encountered: