fix(service-worker): ensure SW stays alive while notifying clients about unrecoverable state (#40234)
Previously, the `Driver#notifyClientsAboutUnrecoverableState()` method would not wait for the completion of the promises created to notify the clients. Theoretically, this could result in the SW instance's getting destroyed by the browser before all clients have been notified. This is extremely unlikely to happen in practice, since the async operations are very quick, but it _is_ theoretically possible. This commit ensures that the SW instance will remain alive while notifying the clients by making `notifyClientsAboutUnrecoverableState()` await the notification promises. PR Close #40234
This commit is contained in:
parent
4bb067d738
commit
ad3329a78b
|
@ -1026,10 +1026,10 @@ export class Driver implements Debuggable, UpdateSource {
|
|||
.filter(([clientId, hash]) => hash === brokenHash)
|
||||
.map(([clientId]) => clientId);
|
||||
|
||||
affectedClients.forEach(async clientId => {
|
||||
await Promise.all(affectedClients.map(async clientId => {
|
||||
const client = await this.scope.clients.get(clientId);
|
||||
client.postMessage({type: 'UNRECOVERABLE_STATE', reason});
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
async notifyClientsAboutUpdate(next: AppVersion): Promise<void> {
|
||||
|
|
Loading…
Reference in New Issue