Clean up fetch code

This commit is contained in:
Gigiaj 2025-06-08 20:05:28 -05:00
parent 3b62beabf1
commit 1d4864592f

View file

@ -65,11 +65,11 @@ self.addEventListener('fetch', (event: FetchEvent) => {
} }
event.respondWith( event.respondWith(
(async (): Promise<Response> => { (async (): Promise<Response> => {
console.log('Unironic race condition mitigation it seems.');
const client = await self.clients.get(event.clientId); const client = await self.clients.get(event.clientId);
let token: string | undefined; const token: string = await sendAndWaitForReply(client, 'token', {});
if (client) token = await askForAccessToken(client); const response = await fetch(url, fetchConfig(token));
return response;
return fetch(url, fetchConfig(token));
})() })()
); );
}); });