Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
Increase token renewal threshold to 3 min (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
kimlisa authored Mar 9, 2021
1 parent 2c49a0f commit 0ec62c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/shared/components/TextEditor/TextEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class TextEditor extends React.Component {
undoManager.markClean();
session.setUndoManager(undoManager);
session.setUseWrapMode(false);
session.setMode(mode);
session.setOptions({ tabSize, useSoftTabs: true, useWorker: false });
session.setMode(mode);
return session;
}

Expand Down
14 changes: 8 additions & 6 deletions packages/teleport/src/services/session/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import localStorage, {
BearerToken,
} from 'teleport/services/localStorage';

// Time to determine when to renew session which is
// when expiry time of token is less than 3 minutes.
const RENEW_TOKEN_TIME = 180 * 1000
const TOKEN_CHECKER_INTERVAL = 15 * 1000; // every 15 sec
const logger = Logger.create('services/session');

Expand Down Expand Up @@ -109,12 +112,11 @@ const session = {
return false;
}

/*
* increase the threshold value for slow connections to avoid
* access-denied response due to concurrent renew token request
* made from another tab.
*/
return this._timeLeft() < TOKEN_CHECKER_INTERVAL * 1.5;
// Renew session if token expiry time is less than 3 minutes.
// Browsers have js timer throttling behavior in inactive tabs that can go
// up to 100s between timer calls from testing. 3 minutes seems to be a safe number
// with extra padding.
return this._timeLeft() < RENEW_TOKEN_TIME;
},

_renewToken(requestId?: string) {
Expand Down

0 comments on commit 0ec62c1

Please sign in to comment.