Skip to content
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

Handling errors in onSync causes infinite loop. #1937

Closed
chimon2000 opened this issue Mar 4, 2019 · 2 comments
Closed

Handling errors in onSync causes infinite loop. #1937

chimon2000 opened this issue Mar 4, 2019 · 2 comments
Assignees
Labels
Bug An issue with our existing, production codebase. workbox-background-sync

Comments

@chimon2000
Copy link

Library Affected:
workbox-background-sync

Browser & Platform:
Google Chrome v72.0

Issue or Feature Request Description:
I am attempting to override the onSync method such that failing status codes add the request back to the queue:

                const response = await fetch(entry.request.clone())

                if ([504, 500].includes(response.status)) {
                    throw new Error('Cannot reach server')
                }

This results in an infinite loop of syncs to occur.

image

@chimon2000
Copy link
Author

I believe this happens because adding a request back to the queue causes a new sync to be triggered.

await this._queueStore[`${operation}Entry`](entry);
await this.registerSync();

@jeffposnick
Copy link
Contributor

CC: @philipwalton for visibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug An issue with our existing, production codebase. workbox-background-sync
Projects
None yet
Development

No branches or pull requests

3 participants