diff --git a/src/sql/platform/connection/browser/connectionManagementService.ts b/src/sql/platform/connection/browser/connectionManagementService.ts index ff28c352e9..c05a03e6d9 100644 --- a/src/sql/platform/connection/browser/connectionManagementService.ts +++ b/src/sql/platform/connection/browser/connectionManagementService.ts @@ -246,6 +246,9 @@ export class ConnectionManagementService extends Disposable implements IConnecti if (!connectionResult.connected && !connectionResult.errorHandled) { // If connection fails show the dialog return this.showConnectionDialogOnError(connection, owner, connectionResult, options); + } else if (!connectionResult.connected && connectionResult.errorHandled) { + // Cancelled firewall dialog + return undefined; } else { //Resolve with the connection result return connectionResult; diff --git a/src/sql/platform/connection/test/browser/connectionManagementService.test.ts b/src/sql/platform/connection/test/browser/connectionManagementService.test.ts index ddf4669644..f316c4bdbd 100644 --- a/src/sql/platform/connection/test/browser/connectionManagementService.test.ts +++ b/src/sql/platform/connection/test/browser/connectionManagementService.test.ts @@ -593,8 +593,7 @@ suite('SQL ConnectionManagementService tests', () => { }; connect(uri, options, false, connectionProfile, error, errorCode, errorCallStack).then(result => { - assert.equal(result.connected, expectedConnection); - assert.equal(result.errorMessage, connectionResult.errorMessage); + assert.equal(result, undefined); verifyShowFirewallRuleDialog(connectionProfile, true); verifyShowConnectionDialog(connectionProfile, ConnectionType.default, uri, true, connectionResult, false); done(); diff --git a/src/sql/workbench/parts/objectExplorer/browser/objectExplorerViewTreeShim.ts b/src/sql/workbench/parts/objectExplorer/browser/objectExplorerViewTreeShim.ts index 8e0038670f..227f805924 100644 --- a/src/sql/workbench/parts/objectExplorer/browser/objectExplorerViewTreeShim.ts +++ b/src/sql/workbench/parts/objectExplorer/browser/objectExplorerViewTreeShim.ts @@ -83,7 +83,7 @@ export class OEShimService extends Disposable implements IOEShimService { private async connectOrPrompt(connProfile: ConnectionProfile): Promise { connProfile = await new Promise(async (resolve, reject) => { - await this.cm.connect(connProfile, undefined, { showConnectionDialogOnError: true, showFirewallRuleOnError: true, saveTheConnection: false, showDashboard: false, params: undefined }, { + let result = await this.cm.connect(connProfile, undefined, { showConnectionDialogOnError: true, showFirewallRuleOnError: true, saveTheConnection: false, showDashboard: false, params: undefined }, { onConnectSuccess: async (e, profile) => { let existingConnection = this.cm.findExistingConnection(profile); connProfile = new ConnectionProfile(this.capabilities, existingConnection); @@ -97,6 +97,10 @@ export class OEShimService extends Disposable implements IOEShimService { onConnectStart: undefined, onDisconnect: undefined }); + // connection cancelled from firewall dialog + if (!result) { + reject(new UserCancelledConnectionError(localize('firewallCanceled', "Firewall dialog canceled"))); + } }); return connProfile; }