shell env - timeout after 10s of trying
This commit is contained in:
parent
505dfc7a06
commit
eaf29b7e24
2 changed files with 26 additions and 10 deletions
|
@ -81,7 +81,6 @@ import { IKeyboardLayoutMainService, KeyboardLayoutMainService } from 'vs/platfo
|
||||||
import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
|
import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
|
||||||
import { isLaunchedFromCli } from 'vs/platform/environment/node/argvHelper';
|
import { isLaunchedFromCli } from 'vs/platform/environment/node/argvHelper';
|
||||||
import { isEqualOrParent } from 'vs/base/common/extpath';
|
import { isEqualOrParent } from 'vs/base/common/extpath';
|
||||||
import { RunOnceScheduler } from 'vs/base/common/async';
|
|
||||||
import { IExtensionUrlTrustService } from 'vs/platform/extensionManagement/common/extensionUrlTrust';
|
import { IExtensionUrlTrustService } from 'vs/platform/extensionManagement/common/extensionUrlTrust';
|
||||||
import { ExtensionUrlTrustService } from 'vs/platform/extensionManagement/node/extensionUrlTrustService';
|
import { ExtensionUrlTrustService } from 'vs/platform/extensionManagement/node/extensionUrlTrustService';
|
||||||
import { once } from 'vs/base/common/functional';
|
import { once } from 'vs/base/common/functional';
|
||||||
|
@ -998,14 +997,7 @@ export class CodeApplication extends Disposable {
|
||||||
// Start to fetch shell environment (if needed) after window has opened
|
// Start to fetch shell environment (if needed) after window has opened
|
||||||
// Since this operation can take a long time, we want to warm it up while
|
// Since this operation can take a long time, we want to warm it up while
|
||||||
// the window is opening.
|
// the window is opening.
|
||||||
// We also print a warning if the resolution takes longer than 10s.
|
resolveShellEnv(this.logService, this.environmentMainService.args, process.env);
|
||||||
(async () => {
|
|
||||||
const slowResolveShellEnvWarning = this._register(new RunOnceScheduler(() => this.logService.warn('Resolving your shell environment is taking more than 10s. Please review your shell configuration. Learn more at https://go.microsoft.com/fwlink/?linkid=2149667.'), 10000));
|
|
||||||
slowResolveShellEnvWarning.schedule();
|
|
||||||
|
|
||||||
await resolveShellEnv(this.logService, this.environmentMainService.args, process.env);
|
|
||||||
slowResolveShellEnvWarning.dispose();
|
|
||||||
})();
|
|
||||||
|
|
||||||
// If enable-crash-reporter argv is undefined then this is a fresh start,
|
// If enable-crash-reporter argv is undefined then this is a fresh start,
|
||||||
// based on telemetry.enableCrashreporter settings, generate a UUID which
|
// based on telemetry.enableCrashreporter settings, generate a UUID which
|
||||||
|
|
|
@ -49,8 +49,32 @@ export async function resolveShellEnv(logService: ILogService, args: NativeParse
|
||||||
logService.trace('resolveShellEnv(): running (macOS/Linux)');
|
logService.trace('resolveShellEnv(): running (macOS/Linux)');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Call this only once and cache the promise for
|
||||||
|
// subsequent calls since this operation can be
|
||||||
|
// expensive (spawns a process).
|
||||||
if (!unixShellEnvPromise) {
|
if (!unixShellEnvPromise) {
|
||||||
unixShellEnvPromise = doResolveUnixShellEnv(logService);
|
unixShellEnvPromise = new Promise(async resolve => {
|
||||||
|
|
||||||
|
// Give up resolving shell env after 10 seconds
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
logService.error(`[resolve shell env] Could not resolve shell environment within 10 seconds. Proceeding without shell environment...`);
|
||||||
|
|
||||||
|
resolve({});
|
||||||
|
}, 10000);
|
||||||
|
|
||||||
|
// Resolve shell env and handle errors
|
||||||
|
try {
|
||||||
|
const shellEnv = await doResolveUnixShellEnv(logService);
|
||||||
|
|
||||||
|
resolve(shellEnv);
|
||||||
|
} catch (error) {
|
||||||
|
logService.error(`[resolve shell env] Unable to resolve shell environment (${error}). Proceeding without shell environment...`);
|
||||||
|
|
||||||
|
resolve({});
|
||||||
|
} finally {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return unixShellEnvPromise;
|
return unixShellEnvPromise;
|
||||||
|
|
Loading…
Reference in a new issue