Skip to content

Too many logs and errors for OidcKeepAliveServiceWorker fetches  #1350

@wermanoid

Description

@wermanoid

Issue and Steps to Reproduce

Too much failed requests when trying to fetch OidcKeepAliveServiceWorker.json, that leads to bunch of errors in network tab and console logs. Also process is random and sometimes it could stay clean for some time.

To Reproduce

You need just run OIDC client with tokens refresh and wait until OidcKeepAliveServiceWorker will start randomly write error logs

Versions

Latest

Screenshots

image
image

Expected

Library should not spam error logs into console, especially when error is random and does not impact on app. This is confusing

Actual

Too much errors in browser.

Additional Details

In OidcServiceWorker.ts there is a function keepAlive and it has this randomiser:

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());
}

Problem is next:

  • Chrome oob timeout: 300 sec
  • Firefox oob timeour: 90 sec

And it is weird, that random function over 150 times resolves into same values (like we have always sleep(2000) result). Here, my assumption, this also might be related to sleep function implementation. As it triggers setTimeout, there is no guarantee that this timeout will be executed immediately, as other functions in app/service worker could also inject some functions into browser call stack. So that leads to longer delays.

This leads to situation when network tab and console are overwhelmed with errors, as this timer:

  • always higher then Firefox threshold
  • regularly (but randomly) exceed 5min in Chrome

Proposals

Not sure what could be better, but some ideas:

  • make it configurable from client side
  • make it adjustable according to different browsers limits
  • just make it once per 25 sec without any randomizer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions