refactor(service-worker): notify clients about updates in parallel (#40234)
Previously, clients were notified about updates sequentially. This wasn't necessary. This commit changes the `Driver#notifyClientsAboutUpdate()` method to notify the clients in parallel (by switching from `Array#reduce()` to `Array#map()` and `Promise.all()`). This also aligns the `notifyClientsAboutUpdate()` method with the `notifyClientsAboutUnrecoverableState()` method. PR Close #40234
This commit is contained in:
parent
ad3329a78b
commit
b953a0c5a5
|
@ -1037,9 +1037,7 @@ export class Driver implements Debuggable, UpdateSource {
|
|||
|
||||
const clients = await this.scope.clients.matchAll();
|
||||
|
||||
await clients.reduce(async (previous, client) => {
|
||||
await previous;
|
||||
|
||||
await Promise.all(clients.map(async client => {
|
||||
// Firstly, determine which version this client is on.
|
||||
const version = this.clientVersionMap.get(client.id);
|
||||
if (version === undefined) {
|
||||
|
@ -1062,7 +1060,7 @@ export class Driver implements Debuggable, UpdateSource {
|
|||
};
|
||||
|
||||
client.postMessage(notice);
|
||||
}, Promise.resolve());
|
||||
}));
|
||||
}
|
||||
|
||||
async broadcast(msg: Object): Promise<void> {
|
||||
|
|
Loading…
Reference in New Issue