Search code examples
service-workerworkboxbackground-sync

What happens to request in workbox backgroundSync queue after lastChance boolean is true?


I am seeing an issue that has my requests being popped off a workbox.backgroundSync.Queue queue after 3 unsuccessful requests. I'm also unable to find solid documentation about the expected behavior after 3 unsuccessful sync requests when the lastChance flag has been set to true.

What is supposed to happen next? Is the request supposed to remain in the queue and what can be done to eventually trigger a replay?


Solution

  • The request will remain in the queue until maxRetentionTime is reached. see maxRetentionTime

    If the flag lastChance is set to true, automatic retries will stop but you can trigger a replayRequests by sending a message to the service worker like:

    self.addEventListener('message', (event) => {
      if (event.data.type === 'replayQueue') {
        myQueue.replayRequests();
      }
    });