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:
parent
90abfc479a
commit
9e3a05e087
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user