1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

fix handling of no timeout

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
Jim Ehrismann 2021-06-08 09:39:25 -04:00
parent 90abfc479a
commit 9e3a05e087

View File

@ -31,14 +31,20 @@ let shellSyncFailed = false;
export async function shellEnv(shell?: string, timeout?: number) : Promise<EnvironmentVariables> {
let envVars = {};
timeout ??= 0;
if (!shellSyncFailed) {
try {
envVars = await Promise.race([
shellEnvironment(shell),
new Promise((_resolve, reject) => setTimeout(() => {
reject(new Error("Resolving shell environment is taking very long. Please review your shell configuration."));
}, timeout))
]);
if (timeout > 0 ) {
envVars = await Promise.race([
shellEnvironment(shell),
new Promise((_resolve, reject) => setTimeout(() => {
reject(new Error("Resolving shell environment is taking very long. Please review your shell configuration."));
}, timeout))
]);
} else {
envVars = await shellEnvironment(shell);
}
} catch (error) {
logger.error(`shellEnv: ${error}`);
shellSyncFailed = true;