lastChance布尔值为true后,workbox backgroundSync队列中的请求会发生什么?

问题描述 投票:1回答:1

我看到一个问题,即在3次请求失败后,我的请求会从workbox.backgroundSync.Queue队列中弹出。当lastChance标志设置为true时,我也无法找到有关3次不成功同步请求后的预期行为的可靠文档。

接下来会发生什么?请求是否应该保留在队列中,以及最终可以执行哪些操作来触发重放?

service-worker workbox background-sync
1个回答
1
投票

请求将保留在队列中,直到达到maxRetentionTime。 see maxRetentionTime

如果标志lastChance设置为true,则自动重试将停止,但您可以通过向服务工作者发送消息来触发重放请求,如:

self.addEventListener('message', (event) => {
  if (event.data.type === 'replayQueue') {
    myQueue.replayRequests();
  }
});
© www.soinside.com 2019 - 2024. All rights reserved.