8000 use more sensible values for timeouts/renewals (#14638) · arangodb/arangodb@967afe0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 967afe0

Browse files
authored
use more sensible values for timeouts/renewals (#14638)
1 parent 64bf322 commit 967afe0

File tree

1 file changed

+14
-3
lines changed
  • js/apps/system/_admin/aardvark/APP/frontend/js/views

1 file changed

+14
-3
lines changed

js/apps/system/_admin/aardvark/APP/frontend/js/views/footerView.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,31 @@
5656
// only try to renew token if we are still online
5757
return;
5858
}
59+
60+
var frac = (frontendConfig.sessionTimeout >= 1800) ? 0.95 : 0.8;
61+
// threshold for renewal: once session is x% over
62+
var renewalThreshold = frontendConfig.sessionTimeout * frac;
5963

6064
var now = Date.now() / 1000;
6165
var lastActivity = arangoHelper.lastActivity();
6266

63-
if (lastActivity > 0 && (now - lastActivity) > 90 * 60) {
67+
// seconds in which the last user activity counts as significant
68+
var lastSignificantActivityTimePeriod = 90 * 60;
69+
70+
// if this is more than the renewal threshold, limit it
71+
if (lastSignificantActivityTimePeriod > renewalThreshold * 0.95) {
72+
lastSignificantActivityTimePeriod = renewalThreshold * 0.95;
73+
}
74+
75+
if (lastActivity > 0 && (now - lastActivity) > lastSignificantActivityTimePeriod) {
6476
// don't make an attempt to renew the token if last
6577
// user activity is longer than 90 minutes ago
6678
return;
6779
}
6880

6981
// to save some superfluous HTTP requests to the server,
7082
// try to renew only if session time is x% or more over
71-
var frac = (frontendConfig.sessionTimeout >= 1800) ? 0.95 : 0.8;
72-
if (now - self.lastTokenRenewal < frontendConfig.sessionTimeout * frac) {
83+
if (now - self.lastTokenRenewal < renewalThreshold) {
7384
return;
7485
}
7586

0 commit comments

Comments
 (0)
0