Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: refresh access token on LSP WebSocket reconnection (#19207)

p0nya1b469246ba3
diff --git a/frontend/src/components/MonacoEditor/lsp-client.ts b/frontend/src/components/MonacoEditor/lsp-client.ts
index 4c9a0e793b..c56eda3b42 100644
--- a/frontend/src/components/MonacoEditor/lsp-client.ts
+++ b/frontend/src/components/MonacoEditor/lsp-client.ts
@@ -8,6 +8,7 @@ import {
WebSocketMessageWriter,
} from "vscode-ws-jsonrpc";
import { shallowReactive, toRef } from "vue";
+import { refreshTokens } from "@/connect/refreshToken";
import { sleep } from "@/utils";
import {
createUrl,
@@ -178,6 +179,11 @@ const createLanguageClient = async (): Promise<MonacoLanguageClient> => {
console.debug("[MonacoLanguageClient] closed");
conn.ws = undefined;
try {
+ // The WebSocket relies on the access-token cookie which
+ // may have expired. Refresh first so the reconnection
+ // uses a valid cookie. refreshTokens() deduplicates
+ // concurrent calls via Web Lock API.
+ await refreshTokens();
await connectWebSocket();
return {
action: CloseAction.Restart,