Skip to content

Commit 0619585

Browse files
Set a short timeout when checking the identity of the authenticated user
1 parent 8a21408 commit 0619585

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

lib/logic/api/helper.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const { printError } = require('../../interface/cli/helpers/general');
88

99
const { version } = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../../package.json')));
1010

11-
const sendHttpRequest = async (httpOptions, authContext, throwOnUnauthorized) => {
11+
const sendHttpRequest = async (httpOptions, authContext, throwOnUnauthorized, timeout = 30000) => {
1212
let finalAuthContext;
1313
if (!authContext) {
1414
const authManager = require('../auth').manager; // eslint-disable-line
@@ -22,6 +22,7 @@ const sendHttpRequest = async (httpOptions, authContext, throwOnUnauthorized) =>
2222
finalAuthContext.prepareHttpOptions(),
2323
{
2424
json: true,
25+
timeout,
2526
headers: {
2627
'User-Agent': `codefresh-cli-v${version}`,
2728
'Codefresh-Agent': 'cli',

lib/logic/auth/contexts/whoami.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const whoami = async (context) => {
88
url: '/api/user/',
99
method: 'GET',
1010
};
11-
const user = await sendHttpRequest(userOptions, context, true);
11+
const user = await sendHttpRequest(userOptions, context, true, 2000);
1212
const accounts = _.get(user, 'account', {});
1313
const accountInfo = _.chain(accounts)
1414
.filter(account => account.name === user.activeAccountName)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codefresh",
3-
"version": "0.8.58",
3+
"version": "0.8.59",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)