-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2 hour OAuth token refresh timer is probably unreliable #81
Comments
Once #80 merges, I think this just becomes a case of running a timer that pings |
Sounds like a good solution. 👍 As long as it's just a local timer checking every, say, 2 minutes(?) if the local token.expiryDatetime >= Date.now(), then there should be no performance issues that I can think of. JavaScript timers/timeouts do appear to suspend when the computer goes to sleep/hibernate mode, (i.e. time asleep doesn't count) and to be sure, I'm running this code - |
Thanks for testing this @shaunanoordin. I'm wondering if some of the errors you are seeing from long sessions on www.antislaverymanuscripts.org come from this timer not working as intended. |
👌 OK, I can super confirm the hypothesis. Set timeout for 3 minutes at 18:08, then put computer to sleep. Woke computer up at 18:22, timeout's alert() kicked in at 18:25. Time asleep doesn't count towards timers/timeouts. |
panoptes-javascript-client/lib/oauth.js
Lines 245 to 247 in 965580b
The OAuth module sets a 2 hour javascript timer when it receives a new token, basically to remind itself to refresh the token when that timer expires. @shaunanoordin raised a good point about this in conversation on Slack. Suppose the timer starts, runs for an hour or so, then my computer goes to sleep. Is timer state preserved when the computer wakes again? If the computer wakes after the timer has expired, will the
refresh
function still run?A better solution would be to either hand off responsibility for checking the token to the client app, as per #80, or use a much shorter timer eg. check token validity every few minutes or so, renewing the timer (if the token is still valid) until the token expires or the browser tab closes.
The text was updated successfully, but these errors were encountered: