You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I run oh.keepalive() but it only runs the ping once and stops working after that. I did some investigation (using lots of console logs!) and learned some things about our implementation. oh.ping relies on debounce, copied from underscore.js. All the functions behave as intended. However:
If the debounced function is set to a wait of N seconds, and N or more seconds have elapsed, running it works as normal. The wait timer is reset.
If N seconds have not elapsed, the function does not run. This is key: the wait timer is reset in this case too.
You can test this by calling oh.ping() every 50 seconds. It will never actually make the whoami request, because its internal counter is reset every time, and can only run once every minute. By default, oh.keepalive tries to run every 60 seconds, but due to a race condition, it thinks the timer hasn't elapsed yet, and then resets it. If you set the keepalive interval to something like 65 seconds, it works just fine.
oh.keepactive also does not work correctly. If the user clicks more than once a minute, no pings will be sent to the server.
I think the issue is that we are using debounce as a throttling function, which is not its intended purpose. Underscore.js has a throttle function (http://underscorejs.org/#throttle) which we should use instead.
The text was updated successfully, but these errors were encountered:
krozett
added a commit
to krozett/ohmage.js
that referenced
this issue
May 18, 2016
I run
oh.keepalive()
but it only runs the ping once and stops working after that. I did some investigation (using lots of console logs!) and learned some things about our implementation.oh.ping
relies ondebounce
, copied from underscore.js. All the functions behave as intended. However:You can test this by calling
oh.ping()
every 50 seconds. It will never actually make thewhoami
request, because its internal counter is reset every time, and can only run once every minute. By default,oh.keepalive
tries to run every 60 seconds, but due to a race condition, it thinks the timer hasn't elapsed yet, and then resets it. If you set the keepalive interval to something like 65 seconds, it works just fine.oh.keepactive
also does not work correctly. If the user clicks more than once a minute, no pings will be sent to the server.I think the issue is that we are using
debounce
as a throttling function, which is not its intended purpose. Underscore.js has athrottle
function (http://underscorejs.org/#throttle) which we should use instead.The text was updated successfully, but these errors were encountered: