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

Quick fix: increase token renewal threshold to 3 min #242

Merged
merged 1 commit into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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