Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
fix(authService): limit setTimeout to it's maximum value of about ca …
Browse files Browse the repository at this point in the history
…24.85d

fixes #375
  • Loading branch information
doktordirk committed Apr 23, 2018
1 parent 6d0f681 commit 3c51df6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/api_authService.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ Sets the login timeout.

CAUTION: .authenticated and isAuthenticated() might get different results when set manually.

WARNING: Maximum timeout is 2^31 - 1 ms (ca. 24.85d).

#### Parameters

| Parameter | Type | Description |
Expand Down
8 changes: 8 additions & 0 deletions src/authService.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ export class AuthService {
* @param {number} ttl Timeout time in ms
*/
setTimeout(ttl: number) {
const maxTimeout = 2147483647; // maximum period in ms (ca. 24.85d) for windows.setTimeout

// limit timer ttl to max value allowed for windows.setTimeout function
if (ttl > maxTimeout) {
ttl = maxTimeout;
logger.warn('Token timeout limited to ', maxTimeout, ' ms (ca 24.85d).');
}

this.clearTimeout();

const expiredTokenHandler = () => {
Expand Down

0 comments on commit 3c51df6

Please sign in to comment.