Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: fix refresh token deadlock (#30828)

wangxiaolei0c2729d9b30c
diff --git a/web/service/refresh-token.ts b/web/service/refresh-token.ts
index 3f63f628a19..998b7f2461c 100644
--- a/web/service/refresh-token.ts
+++ b/web/service/refresh-token.ts
@@ -72,12 +72,12 @@ async function getNewAccessToken(timeout: number): Promise<void> {
}
function releaseRefreshLock() {
- if (isRefreshing) {
- isRefreshing = false
- globalThis.localStorage.removeItem(LOCAL_STORAGE_KEY)
- globalThis.localStorage.removeItem('last_refresh_time')
- globalThis.removeEventListener('beforeunload', releaseRefreshLock)
- }
+ // Always clear the refresh lock to avoid cross-tab deadlocks.
+ // This is safe to call multiple times and from tabs that were only waiting.
+ isRefreshing = false
+ globalThis.localStorage.removeItem(LOCAL_STORAGE_KEY)
+ globalThis.localStorage.removeItem('last_refresh_time')
+ globalThis.removeEventListener('beforeunload', releaseRefreshLock)
}
export async function refreshAccessTokenOrRelogin(timeout: number) {