mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
More dangling promise cleanup (#8518)
* More dangling promise cleanup * return void * Function to async * Fix a couple missed promises
This commit is contained in:
@@ -84,7 +84,7 @@ export class ConfigureDashboardAction extends Task {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
runTask(accessor: ServicesAccessor): Promise<void> {
|
async runTask(accessor: ServicesAccessor): Promise<void> {
|
||||||
return accessor.get(IOpenerService).open(URI.parse(ConfigureDashboardAction.configHelpUri)).then();
|
accessor.get(IOpenerService).open(URI.parse(ConfigureDashboardAction.configHelpUri));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ export class TaskHistoryView extends Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private updateTask(task: TaskNode): void {
|
private updateTask(task: TaskNode): void {
|
||||||
this._tree.refresh(task);
|
this._tree.refresh(task).catch(err => errors.onUnexpectedError(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
public refreshTree(): void {
|
public refreshTree(): void {
|
||||||
|
|||||||
@@ -57,12 +57,12 @@ export class ScriptAction extends Action {
|
|||||||
super(id, label);
|
super(id, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
public run(element: TaskNode): Promise<boolean> {
|
public async run(element: TaskNode): Promise<boolean> {
|
||||||
if (element instanceof TaskNode) {
|
if (element instanceof TaskNode) {
|
||||||
if (element.script && element.script !== '') {
|
if (element.script && element.script !== '') {
|
||||||
this._queryEditorService.newSqlEditor(element.script);
|
this._queryEditorService.newSqlEditor(element.script);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Promise.resolve(true);
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
|
|||||||
import { URI } from 'vs/base/common/uri';
|
import { URI } from 'vs/base/common/uri';
|
||||||
import { firstIndex } from 'vs/base/common/arrays';
|
import { firstIndex } from 'vs/base/common/arrays';
|
||||||
import { values } from 'vs/base/common/collections';
|
import { values } from 'vs/base/common/collections';
|
||||||
|
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||||
|
|
||||||
export class AccountManagementService implements IAccountManagementService {
|
export class AccountManagementService implements IAccountManagementService {
|
||||||
// CONSTANTS ///////////////////////////////////////////////////////////
|
// CONSTANTS ///////////////////////////////////////////////////////////
|
||||||
@@ -314,8 +315,8 @@ export class AccountManagementService implements IAccountManagementService {
|
|||||||
* Copy the user code to the clipboard and open a browser to the verification URI
|
* Copy the user code to the clipboard and open a browser to the verification URI
|
||||||
*/
|
*/
|
||||||
public copyUserCodeAndOpenBrowser(userCode: string, uri: string): void {
|
public copyUserCodeAndOpenBrowser(userCode: string, uri: string): void {
|
||||||
this._clipboardService.writeText(userCode);
|
this._clipboardService.writeText(userCode).catch(err => onUnexpectedError(err));
|
||||||
this._openerService.open(URI.parse(uri));
|
this._openerService.open(URI.parse(uri)).catch(err => onUnexpectedError(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
// SERVICE MANAGEMENT METHODS //////////////////////////////////////////
|
// SERVICE MANAGEMENT METHODS //////////////////////////////////////////
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export class BackupUiService implements IBackupUiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public showBackupDialog(connection: IConnectionProfile): Promise<void> {
|
public async showBackupDialog(connection: IConnectionProfile): Promise<void> {
|
||||||
let self = this;
|
let self = this;
|
||||||
self._connectionUri = ConnectionUtils.generateUri(connection);
|
self._connectionUri = ConnectionUtils.generateUri(connection);
|
||||||
self._currentProvider = connection.providerName;
|
self._currentProvider = connection.providerName;
|
||||||
@@ -79,7 +79,6 @@ export class BackupUiService implements IBackupUiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let backupOptions = this.getOptions(this._currentProvider);
|
let backupOptions = this.getOptions(this._currentProvider);
|
||||||
return new Promise<void>((resolve) => {
|
|
||||||
let uri = this._connectionManagementService.getConnectionUri(connection)
|
let uri = this._connectionManagementService.getConnectionUri(connection)
|
||||||
+ ProviderConnectionInfo.idSeparator
|
+ ProviderConnectionInfo.idSeparator
|
||||||
+ ConnectionUtils.ConnectionUriBackupIdAttributeName
|
+ ConnectionUtils.ConnectionUriBackupIdAttributeName
|
||||||
@@ -90,20 +89,17 @@ export class BackupUiService implements IBackupUiService {
|
|||||||
|
|
||||||
BackupUiService._connectionUniqueId++;
|
BackupUiService._connectionUniqueId++;
|
||||||
|
|
||||||
// Create connection if needed
|
|
||||||
if (!this._connectionManagementService.isConnected(uri)) {
|
|
||||||
this._connectionManagementService.connect(connection, uri).then(() => {
|
|
||||||
this._onShowBackupEvent.fire({ connection: connection, ownerUri: uri });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (backupOptions) {
|
if (backupOptions) {
|
||||||
(backupDialog as OptionsDialog).open(backupOptions, self._optionValues);
|
(backupDialog as OptionsDialog).open(backupOptions, self._optionValues);
|
||||||
} else {
|
} else {
|
||||||
(backupDialog as BackupDialog).open(connection);
|
(backupDialog as BackupDialog).open(connection);
|
||||||
}
|
}
|
||||||
resolve(void 0);
|
|
||||||
});
|
// Create connection if needed
|
||||||
|
if (!this._connectionManagementService.isConnected(uri)) {
|
||||||
|
await this._connectionManagementService.connect(connection, uri);
|
||||||
|
this._onShowBackupEvent.fire({ connection: connection, ownerUri: uri });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public onShowBackupDialog() {
|
public onShowBackupDialog() {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import { IConnectionProviderRegistry, Extensions as ConnectionExtensions } from
|
|||||||
import { ICapabilitiesService, ProviderFeatures, clientCapabilities, ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
|
import { ICapabilitiesService, ProviderFeatures, clientCapabilities, ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||||
import { find } from 'vs/base/common/arrays';
|
import { find } from 'vs/base/common/arrays';
|
||||||
import { entries } from 'sql/base/common/collections';
|
import { entries } from 'sql/base/common/collections';
|
||||||
|
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||||
|
|
||||||
const connectionRegistry = Registry.as<IConnectionProviderRegistry>(ConnectionExtensions.ConnectionProviderContributions);
|
const connectionRegistry = Registry.as<IConnectionProviderRegistry>(ConnectionExtensions.ConnectionProviderContributions);
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ export class CapabilitiesService extends Disposable implements ICapabilitiesServ
|
|||||||
|
|
||||||
extensionService.whenInstalledExtensionsRegistered().then(() => {
|
extensionService.whenInstalledExtensionsRegistered().then(() => {
|
||||||
this.cleanupProviders();
|
this.cleanupProviders();
|
||||||
});
|
}).catch(err => onUnexpectedError(err));
|
||||||
|
|
||||||
_storageService.onWillSaveState(() => this.shutdown());
|
_storageService.onWillSaveState(() => this.shutdown());
|
||||||
|
|
||||||
@@ -85,7 +86,7 @@ export class CapabilitiesService extends Disposable implements ICapabilitiesServ
|
|||||||
let id = extension.contributes[connectionProvider].providerId;
|
let id = extension.contributes[connectionProvider].providerId;
|
||||||
delete this.capabilities.connectionProviderCache[id];
|
delete this.capabilities.connectionProviderCache[id];
|
||||||
}
|
}
|
||||||
});
|
}).catch(err => onUnexpectedError(err));
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
|
|||||||
import { CmsConnectionController } from 'sql/workbench/services/connection/browser/cmsConnectionController';
|
import { CmsConnectionController } from 'sql/workbench/services/connection/browser/cmsConnectionController';
|
||||||
import { entries } from 'sql/base/common/collections';
|
import { entries } from 'sql/base/common/collections';
|
||||||
import { find } from 'vs/base/common/arrays';
|
import { find } from 'vs/base/common/arrays';
|
||||||
|
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||||
|
|
||||||
export interface IConnectionValidateResult {
|
export interface IConnectionValidateResult {
|
||||||
isValid: boolean;
|
isValid: boolean;
|
||||||
@@ -181,12 +182,12 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
|||||||
profile.savePassword = true;
|
profile.savePassword = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.handleDefaultOnConnect(params, profile);
|
this.handleDefaultOnConnect(params, profile).catch(err => onUnexpectedError(err));
|
||||||
} else {
|
} else {
|
||||||
profile.serverName = trim(profile.serverName);
|
profile.serverName = trim(profile.serverName);
|
||||||
this._connectionManagementService.addSavedPassword(profile).then(connectionWithPassword => {
|
this._connectionManagementService.addSavedPassword(profile).then(async (connectionWithPassword) => {
|
||||||
this.handleDefaultOnConnect(params, connectionWithPassword);
|
await this.handleDefaultOnConnect(params, connectionWithPassword);
|
||||||
});
|
}).catch(err => onUnexpectedError(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,14 +220,14 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleDefaultOnConnect(params: INewConnectionParams, connection: IConnectionProfile): Thenable<void> {
|
private async handleDefaultOnConnect(params: INewConnectionParams, connection: IConnectionProfile): Promise<void> {
|
||||||
if (this.ignoreNextConnect) {
|
if (this.ignoreNextConnect) {
|
||||||
this._connectionDialog.resetConnection();
|
this._connectionDialog.resetConnection();
|
||||||
this._connectionDialog.close();
|
this._connectionDialog.close();
|
||||||
this.ignoreNextConnect = false;
|
this.ignoreNextConnect = false;
|
||||||
this._connecting = false;
|
this._connecting = false;
|
||||||
this._dialogDeferredPromise.resolve(connection);
|
this._dialogDeferredPromise.resolve(connection);
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
let fromEditor = params && params.connectionType === ConnectionType.editor;
|
let fromEditor = params && params.connectionType === ConnectionType.editor;
|
||||||
let isTemporaryConnection = params && params.connectionType === ConnectionType.temporary;
|
let isTemporaryConnection = params && params.connectionType === ConnectionType.temporary;
|
||||||
@@ -242,7 +243,8 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
|||||||
showFirewallRuleOnError: true
|
showFirewallRuleOnError: true
|
||||||
};
|
};
|
||||||
|
|
||||||
return this._connectionManagementService.connectAndSaveProfile(connection, uri, options, params && params.input).then(connectionResult => {
|
try {
|
||||||
|
const connectionResult = await this._connectionManagementService.connectAndSaveProfile(connection, uri, options, params && params.input);
|
||||||
this._connecting = false;
|
this._connecting = false;
|
||||||
if (connectionResult && connectionResult.connected) {
|
if (connectionResult && connectionResult.connected) {
|
||||||
this._connectionDialog.close();
|
this._connectionDialog.close();
|
||||||
@@ -255,11 +257,11 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
|||||||
this._connectionDialog.resetConnection();
|
this._connectionDialog.resetConnection();
|
||||||
this.showErrorDialog(Severity.Error, this._connectionErrorTitle, connectionResult.errorMessage, connectionResult.callStack);
|
this.showErrorDialog(Severity.Error, this._connectionErrorTitle, connectionResult.errorMessage, connectionResult.callStack);
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
} catch (err) {
|
||||||
this._connecting = false;
|
this._connecting = false;
|
||||||
this._connectionDialog.resetConnection();
|
this._connectionDialog.resetConnection();
|
||||||
this.showErrorDialog(Severity.Error, this._connectionErrorTitle, err);
|
this.showErrorDialog(Severity.Error, this._connectionErrorTitle, err);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private get uiController(): IConnectionComponentController {
|
private get uiController(): IConnectionComponentController {
|
||||||
@@ -339,7 +341,7 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
|||||||
this._model = this.createModel(connectionWithPassword);
|
this._model = this.createModel(connectionWithPassword);
|
||||||
|
|
||||||
this.uiController.fillInConnectionInputs(this._model);
|
this.uiController.fillInConnectionInputs(this._model);
|
||||||
});
|
}).catch(err => onUnexpectedError(err));
|
||||||
this._connectionDialog.updateProvider(this._providerNameToDisplayNameMap[connectionInfo.providerName]);
|
this._connectionDialog.updateProvider(this._providerNameToDisplayNameMap[connectionInfo.providerName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,12 +383,9 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
|||||||
return newProfile;
|
return newProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
private showDialogWithModel(): Promise<void> {
|
private async showDialogWithModel(): Promise<void> {
|
||||||
return new Promise<void>((resolve, reject) => {
|
|
||||||
this.updateModelServerCapabilities(this._inputModel);
|
this.updateModelServerCapabilities(this._inputModel);
|
||||||
this.doShowDialog(this._params);
|
await this.doShowDialog(this._params);
|
||||||
resolve(null);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public openDialogAndWait(
|
public openDialogAndWait(
|
||||||
@@ -438,7 +437,7 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private doShowDialog(params: INewConnectionParams): Promise<void> {
|
private async doShowDialog(params: INewConnectionParams): Promise<void> {
|
||||||
if (!this._connectionDialog) {
|
if (!this._connectionDialog) {
|
||||||
this._connectionDialog = this._instantiationService.createInstance(ConnectionDialogWidget, this._providerDisplayNames, this._providerNameToDisplayNameMap[this._model.providerName], this._providerNameToDisplayNameMap);
|
this._connectionDialog = this._instantiationService.createInstance(ConnectionDialogWidget, this._providerDisplayNames, this._providerNameToDisplayNameMap[this._model.providerName], this._providerNameToDisplayNameMap);
|
||||||
this._connectionDialog.onCancel(() => {
|
this._connectionDialog.onCancel(() => {
|
||||||
@@ -457,12 +456,10 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
|||||||
this._connectionDialog.newConnectionParams = params;
|
this._connectionDialog.newConnectionParams = params;
|
||||||
this._connectionDialog.updateProvider(this._providerNameToDisplayNameMap[this._currentProviderType]);
|
this._connectionDialog.updateProvider(this._providerNameToDisplayNameMap[this._currentProviderType]);
|
||||||
|
|
||||||
return new Promise<void>(() => {
|
|
||||||
const recentConnections: ConnectionProfile[] = this._connectionManagementService.getRecentConnections(params.providers);
|
const recentConnections: ConnectionProfile[] = this._connectionManagementService.getRecentConnections(params.providers);
|
||||||
this._connectionDialog.open(recentConnections.length > 0);
|
await this._connectionDialog.open(recentConnections.length > 0);
|
||||||
this.uiController.focusOnOpen();
|
this.uiController.focusOnOpen();
|
||||||
recentConnections.forEach(conn => conn.dispose());
|
recentConnections.forEach(conn => conn.dispose());
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private showErrorDialog(severity: Severity, headerTitle: string, message: string, messageDetails?: string): void {
|
private showErrorDialog(severity: Severity, headerTitle: string, message: string, messageDetails?: string): void {
|
||||||
@@ -477,16 +474,15 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
|||||||
localize('kerberosHelpLink', "Help configuring Kerberos is available at {0}", helpLink),
|
localize('kerberosHelpLink', "Help configuring Kerberos is available at {0}", helpLink),
|
||||||
localize('kerberosKinit', "If you have previously connected you may need to re-run kinit.")
|
localize('kerberosKinit', "If you have previously connected you may need to re-run kinit.")
|
||||||
].join('\r\n');
|
].join('\r\n');
|
||||||
actions.push(new Action('Kinit', 'Run kinit', null, true, () => {
|
actions.push(new Action('Kinit', 'Run kinit', null, true, async () => {
|
||||||
this._connectionDialog.close();
|
this._connectionDialog.close();
|
||||||
this._clipboardService.writeText('kinit\r');
|
await this._clipboardService.writeText('kinit\r');
|
||||||
this._commandService.executeCommand('workbench.action.terminal.focus').then(resolve => {
|
await this._commandService.executeCommand('workbench.action.terminal.focus');
|
||||||
// setTimeout to allow for terminal Instance to load.
|
// setTimeout to allow for terminal Instance to load.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
return this._commandService.executeCommand('workbench.action.terminal.paste');
|
return this._commandService.executeCommand('workbench.action.terminal.paste');
|
||||||
}, 10);
|
}, 10);
|
||||||
}).then(resolve => null, reject => null);
|
return;
|
||||||
return null;
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,9 +214,8 @@ suite('SQL ConnectionManagementService tests', () => {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect(uri: string, options?: IConnectionCompletionOptions, fromDialog?: boolean, connection?: IConnectionProfile, error?: string, errorCode?: number, errorCallStack?: string): Promise<IConnectionResult> {
|
async function connect(uri: string, options?: IConnectionCompletionOptions, fromDialog?: boolean, connection?: IConnectionProfile, error?: string, errorCode?: number, errorCallStack?: string): Promise<IConnectionResult> {
|
||||||
let connectionToUse = connection ? connection : connectionProfile;
|
let connectionToUse = connection ? connection : connectionProfile;
|
||||||
return new Promise<IConnectionResult>((resolve, reject) => {
|
|
||||||
let id = connectionToUse.getOptionsKey();
|
let id = connectionToUse.getOptionsKey();
|
||||||
let defaultUri = 'connection:' + (id ? id : connectionToUse.serverName + ':' + connectionToUse.databaseName);
|
let defaultUri = 'connection:' + (id ? id : connectionToUse.serverName + ':' + connectionToUse.databaseName);
|
||||||
connectionManagementService.onConnectionRequestSent(() => {
|
connectionManagementService.onConnectionRequestSent(() => {
|
||||||
@@ -235,14 +234,12 @@ suite('SQL ConnectionManagementService tests', () => {
|
|||||||
};
|
};
|
||||||
connectionManagementService.onConnectionComplete(0, info);
|
connectionManagementService.onConnectionComplete(0, info);
|
||||||
});
|
});
|
||||||
connectionManagementService.cancelConnectionForUri(uri).then(() => {
|
await connectionManagementService.cancelConnectionForUri(uri);
|
||||||
if (fromDialog) {
|
if (fromDialog) {
|
||||||
resolve(connectionManagementService.connectAndSaveProfile(connectionToUse, uri, options));
|
return connectionManagementService.connectAndSaveProfile(connectionToUse, uri, options);
|
||||||
} else {
|
} else {
|
||||||
resolve(connectionManagementService.connect(connectionToUse, uri, options));
|
return connectionManagementService.connect(connectionToUse, uri, options);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test('showConnectionDialog should open the dialog with default type given no parameters', done => {
|
test('showConnectionDialog should open the dialog with default type given no parameters', done => {
|
||||||
|
|||||||
Reference in New Issue
Block a user