fix(web): avoid service-worker activation deadlock

This commit is contained in:
2026-10-14 18:30:06 -07:00
parent 8b125c13a5
commit 844f48e9e0
2 changed files with 58 additions and 15 deletions
+3 -15
View File
@@ -3,21 +3,9 @@ self.addEventListener("install", () => {
});
self.addEventListener("activate", (event) => {
event.waitUntil(
(async () => {
await self.clients.claim();
const windows = await self.clients.matchAll({ type: "window", includeUncontrolled: true });
await Promise.all(
windows.map(async (client) => {
try {
await client.navigate(client.url);
} catch {
// The client may have closed while the new worker was activating.
}
})
);
})()
);
// Navigations through this worker wait for activation. Awaiting a client
// reload here deadlocks first visits, including the token sign-in screen.
event.waitUntil(self.clients.claim());
});
self.addEventListener("fetch", (event) => {