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: skip redundant refresh when broadcast received (#18748)
p0ny10e3c4d50c80
diff --git a/frontend/src/grpcweb/refreshToken.ts b/frontend/src/grpcweb/refreshToken.tsindex 697bab07f1..02a30a2d65 100644--- a/frontend/src/grpcweb/refreshToken.ts+++ b/frontend/src/grpcweb/refreshToken.ts@@ -30,10 +30,12 @@ async function doRefresh(): Promise<void> {}// Another tab is refreshing - wait for broadcast- await waitForBroadcast();+ const receivedBroadcast = await waitForBroadcast();- // After wait, try once more (handles race condition or failed refresh)- await tryAcquireAndRefresh();+ // Only retry if timed out (missed broadcast or other tab failed)+ if (!receivedBroadcast) {+ await tryAcquireAndRefresh();+ }}async function tryAcquireAndRefresh(): Promise<boolean> {@@ -44,33 +46,30 @@ async function tryAcquireAndRefresh(): Promise<boolean> {if (!lock) {return false;}- try {- await authServiceClientConnect.refresh({});- } finally {- // Notify waiting tabs regardless of success/failure- const channel = new BroadcastChannel(CHANNEL_NAME);- channel.postMessage("complete");- channel.close();- }+ await authServiceClientConnect.refresh({});+ // Only broadcast on success - failure lets waiting tabs timeout and retry+ const channel = new BroadcastChannel(CHANNEL_NAME);+ channel.postMessage("complete");+ channel.close();return true;});}-function waitForBroadcast(): Promise<void> {+function waitForBroadcast(): Promise<boolean> {return new Promise((resolve) => {const channel = new BroadcastChannel(CHANNEL_NAME);- const cleanup = () => {+ const cleanup = (received: boolean) => {channel.close();- resolve();+ resolve(received);};- const timeout = setTimeout(cleanup, WAIT_TIMEOUT_MS);+ const timeout = setTimeout(() => cleanup(false), WAIT_TIMEOUT_MS);channel.onmessage = () => {clearTimeout(timeout);- cleanup();+ cleanup(true);};});}