Skip to content

Commit

Permalink
Fixing unsupported providers behavior on Async Server Tree (#23758) (#…
Browse files Browse the repository at this point in the history
…23791)

* Throwing error so that connection loading fails.

* Fixing stuff

* Fixing tests
  • Loading branch information
aasimkhan30 committed Jul 12, 2023
1 parent 90fccfd commit c78b7ca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1368,16 +1368,22 @@ export class ConnectionManagementService extends Disposable implements IConnecti
});

await this._extensionService.activateByEvent(`onConnect:${connection.providerName}`);

if (this._providers.get(connection.providerName) === undefined) {
await this.handleUnsupportedProvider(connection.providerName);
throw new Error(nls.localize('connection.providerNotFound', "Connection provider '{0}' not found", connection.providerName));
}
return this._providers.get(connection.providerName).onReady.then((provider) => {
provider.connect(uri, connectionInfo);
this._onConnectRequestSent.fire();
// Connections are made per URI so while there may possibly be multiple editors with
// that URI they all share the same state
const editor = this._editorService.findEditors(URI.parse(uri))[0]?.editor;
// TODO make this generic enough to handle non-SQL languages too
const language = editor instanceof QueryEditorInput && editor.state.isSqlCmdMode ? 'sqlcmd' : 'sql';
this.doChangeLanguageFlavor(uri, language, connection.providerName);
const editors = this._editorService.findEditors(URI.parse(uri));
if (editors && editors[0]?.editor) {
const editor = editors[0].editor;
// TODO make this generic enough to handle non-SQL languages too
const language = editor instanceof QueryEditorInput && editor.state.isSqlCmdMode ? 'sqlcmd' : 'sql';
this.doChangeLanguageFlavor(uri, language, connection.providerName);
}
return true;
});
}
Expand Down Expand Up @@ -1644,7 +1650,11 @@ export class ConnectionManagementService extends Disposable implements IConnecti
});

// send connection request
self.sendConnectRequest(connection, uri).catch((e) => this._logService.error(e));
self.sendConnectRequest(connection, uri).catch((e) => {
this._logService.error(e);
this._connectionStatusManager.removeConnection(uri);
reject(e);
});
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ export class TreeSelectionHandler {
}
const selectedNode = selection[0];
if (selectedNode instanceof ConnectionProfile && !capabilitiesService.getCapabilities(selectedNode.providerName)) {
connectionManagementService.handleUnsupportedProvider(selectedNode.providerName).catch(onUnexpectedError);
// Async tree handles unsupported providers through the connection management service
if (!(tree instanceof AsyncServerTree)) {
connectionManagementService.handleUnsupportedProvider(selectedNode.providerName).catch(onUnexpectedError);
}
return;
}

Expand Down

0 comments on commit c78b7ca

Please sign in to comment.