AxaFrance / oidc-client

Light, Secure, Pure Javascript OIDC (Open ID Connect) Client. We provide also a REACT wrapper (compatible NextJS, etc.).
MIT License
571 stars 152 forks source link

Service worker keep alive failed to fetch logs #893

Open beanovar opened 1 year ago

beanovar commented 1 year ago

Hi,

Is it possible please to remove the following console.logs and just swallow / ignore it silently instead? https://github.com/AxaGuilDEv/react-oidc/blob/3ec7132a7810a5276b0fc8eaffe1573523fd5534/packages/react/src/oidc/vanilla/initWorker.ts#L44

https://github.com/AxaGuilDEv/react-oidc/blob/3ec7132a7810a5276b0fc8eaffe1573523fd5534/packages/react/src/oidc/vanilla/initWorker.ts#L46

They cause a lot of noise ! :(

Thanks

ronildo commented 1 year ago

Or this could be behind a flag...

guillaume-chervet commented 1 year ago

hi @beanovar and @ronildo,

yearh, I'am agree : A flag would be a good solution. The issue is discussed also here #862. I have a problem, chrome is loggin an error even if we do not set up log. I will be on holiday for 2 weeks. May you wait a little for it ?

Thank you for your issue @beanovar .

guillaume-chervet commented 1 year ago

Hi @ronildo , @beanovar , in the lastest chrome and edge version, i do not have this problem anymore. I do not know why, i think they have made an update on chromiom side.

bkershaw commented 1 year ago

I had similar issues with log errors "failed to fetch /OidcKeepAliveServiceWorker.json"

Inside the serviceWorker, I noticed the hanleFetch function was responding to the event via keepAliveAsync however keepAliveAsync was not being awaited. Once awaited was added, the fetch error was resolved. Unsure if this is best practice, but it did silence the error logs.

const handleFetch = async (event) => {
    const originalRequest = event.request;
    const url = originalRequest.url;
    if (originalRequest.url.includes(keepAliveJsonFilename)) {
        event.respondWith(await keepAliveAsync(event)); // 👈 await added here
        return;
    }
    // .....
}

@axa-fr/react-oidc package version 6.14.10

Zamaletdinov commented 1 year ago

Hi @guillaume-chervet @bkershaw We currently have a similar issue (I tried using different browsers), when I do "Empty Cache and Hard Reload" so:

It really seems that "OidcKeepAliveServiceWorker.json" request isn't handled by the library upon hard refresh Is there anything that could potentially help us?