Skip to content

Commit

Permalink
fix(oidc): decrease minSleepSeconds value to prevent falsy errors and…
Browse files Browse the repository at this point in the history
… logs (alpha)
  • Loading branch information
Kamil Krzempek committed Apr 24, 2024
1 parent 1dd3b41 commit 4a31a1d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions packages/oidc-client-service-worker/src/OidcServiceWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,10 @@ const keepAliveAsync = async (event: FetchEvent) => {
if (!isFromVanilla) {
const originalRequestUrl = new URL(originalRequest.url);
const minSleepSeconds =
Number(originalRequestUrl.searchParams.get('minSleepSeconds')) || 240;
for (let i = 0; i < minSleepSeconds; i++) {
await sleep(1000 + Math.floor(Math.random() * 1000));
const cache = await caches.open('oidc_dummy_cache');
await cache.put(event.request, response.clone());
}
Number(originalRequestUrl.searchParams.get('minSleepSeconds')) || 20;
await sleep(minSleepSeconds * 1000 + Math.floor(Math.random() * 2000));
const cache = await caches.open('oidc_dummy_cache');
await cache.put(event.request, response.clone());
}
return response;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/oidc-client/src/initWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const sleepAsync = ({milliseconds}: { milliseconds: any }) => {

const keepAlive = (service_worker_keep_alive_path='/') => {
try {
const minSleepSeconds = 150;
const minSleepSeconds = 20;
keepAliveController = new AbortController();
const promise = fetch(`${service_worker_keep_alive_path}OidcKeepAliveServiceWorker.json?minSleepSeconds=${minSleepSeconds}`, { signal: keepAliveController.signal });
promise.catch(error => { console.log(error); });
Expand Down

0 comments on commit 4a31a1d

Please sign in to comment.