Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix(sql-editor): start client and executeCommand work more strictly (#2684)
Liu Ji685d3c0a3f12
diff --git a/frontend/src/plugins/sql-lsp/client/useLanguageClient.ts b/frontend/src/plugins/sql-lsp/client/useLanguageClient.tsindex ce51ff762c..a35dad8a88 100644--- a/frontend/src/plugins/sql-lsp/client/useLanguageClient.ts+++ b/frontend/src/plugins/sql-lsp/client/useLanguageClient.ts@@ -50,7 +50,12 @@ const getLanguageClient = () => {};const executeCommand = (params: ExecuteCommandParams) => {+ // Don't go further if we are not connected.+ if (state.stopped) {+ return;+ }getLanguageClient().then((client) => {+ // Double check the status since we are in an async callbackif (state.stopped) {return;}@@ -73,19 +78,32 @@ const changeDialect = (dialect: SQLDialect) => {};const start = () => {+ if (!state.stopped) {+ // Don't start twice+ return;+ }state.client.then((client) => {- client.start();- state.stopped = false;+ if (!state.stopped) {+ // Double check+ return;+ }+ try {+ client.start();+ state.stopped = false;+ } catch {+ // nothing todo+ }});};const stop = () => {+ state.stopped = true;+if (!state.client) {// We don't need to stop if the client is not started yetreturn;}state.client.then((client) => {- state.stopped = true;client.stop();});};