oidc-client-ts icon indicating copy to clipboard operation
oidc-client-ts copied to clipboard

renewal event fail in inactive tab

Open kyugoa opened this issue 1 year ago • 4 comments

most browsers will throttle tab activities to preserve resources and battery life on the user’s device. with that, if a user switch away from the tab, token refresh timer won't work properly. looking at the web, the fix would be using web worker for the timer. should this lib incorporate a fix like that?

kyugoa avatar Apr 06 '23 18:04 kyugoa

This is a known problem. I have the feeling using web worker will make everything even more complex...

pamapa avatar Apr 13 '23 10:04 pamapa

We ran into this issue, too. Is there any good workaround right now?

misl-smlz avatar Jun 23 '23 08:06 misl-smlz

I'm thinking of a solution via the Page Visibility API.

That could be also integrated in oidc-client-ts: Listen to hidden / visible state of the tab and push a refresh call when the tab get's visible again. @pamapa What do you think?

misl-smlz avatar Jun 23 '23 08:06 misl-smlz

Maybe worth a try. Would help for cases where you still have a proper IDP session cookie or a vaild refresh token.

pamapa avatar Jun 23 '23 12:06 pamapa