mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-27 13:40:25 +00:00
Dont do async work on process.on('exit') (#51411)
* Dont do async work on process.on('exit') Fixes #47180
* Refactoring
This commit is contained in:
@@ -64,20 +64,21 @@ class Main {
|
||||
run(argv: ParsedArgs): TPromise<any> {
|
||||
// TODO@joao - make this contributable
|
||||
|
||||
let returnPromise: TPromise<any>;
|
||||
if (argv['install-source']) {
|
||||
return this.setInstallSource(argv['install-source']);
|
||||
returnPromise = this.setInstallSource(argv['install-source']);
|
||||
} else if (argv['list-extensions']) {
|
||||
return this.listExtensions(argv['show-versions']);
|
||||
returnPromise = this.listExtensions(argv['show-versions']);
|
||||
} else if (argv['install-extension']) {
|
||||
const arg = argv['install-extension'];
|
||||
const args: string[] = typeof arg === 'string' ? [arg] : arg;
|
||||
return this.installExtension(args);
|
||||
returnPromise = this.installExtension(args);
|
||||
} else if (argv['uninstall-extension']) {
|
||||
const arg = argv['uninstall-extension'];
|
||||
const ids: string[] = typeof arg === 'string' ? [arg] : arg;
|
||||
return this.uninstallExtension(ids);
|
||||
returnPromise = this.uninstallExtension(ids);
|
||||
}
|
||||
return undefined;
|
||||
return returnPromise || TPromise.as(null);
|
||||
}
|
||||
|
||||
private setInstallSource(installSource: string): TPromise<any> {
|
||||
@@ -221,17 +222,13 @@ export function main(argv: ParsedArgs): TPromise<void> {
|
||||
services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService));
|
||||
services.set(IDialogService, new SyncDescriptor(CommandLineDialogService));
|
||||
|
||||
const appenders: AppInsightsAppender[] = [];
|
||||
if (isBuilt && !extensionDevelopmentPath && !envService.args['disable-telemetry'] && product.enableTelemetry) {
|
||||
const appenders: AppInsightsAppender[] = [];
|
||||
|
||||
if (product.aiConfig && product.aiConfig.asimovKey) {
|
||||
appenders.push(new AppInsightsAppender(eventPrefix, null, product.aiConfig.asimovKey));
|
||||
}
|
||||
|
||||
// It is important to dispose the AI adapter properly because
|
||||
// only then they flush remaining data.
|
||||
process.once('exit', () => appenders.forEach(a => a.dispose()));
|
||||
|
||||
const config: ITelemetryServiceConfig = {
|
||||
appender: combinedAppender(...appenders),
|
||||
commonProperties: resolveCommonProperties(product.commit, pkg.version, stateService.getItem('telemetry.machineId'), installSourcePath),
|
||||
@@ -246,7 +243,10 @@ export function main(argv: ParsedArgs): TPromise<void> {
|
||||
const instantiationService2 = instantiationService.createChild(services);
|
||||
const main = instantiationService2.createInstance(Main);
|
||||
|
||||
return main.run(argv);
|
||||
return main.run(argv).then(() => {
|
||||
// Dispose the AI adapter so that remaining data gets flushed.
|
||||
return combinedAppender(...appenders).dispose();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user