diff --git a/src/platform/auth/session/useSessionCookie.ts b/src/platform/auth/session/useSessionCookie.ts index 38712b115..49f6fec46 100644 --- a/src/platform/auth/session/useSessionCookie.ts +++ b/src/platform/auth/session/useSessionCookie.ts @@ -2,15 +2,6 @@ import { api } from '@/scripts/api' import { isCloud } from '@/platform/distribution/types' import { useFirebaseAuthStore } from '@/stores/firebaseAuthStore' -/** - * Tracks the in-flight createSession request to dedupe concurrent calls. - */ -let createSessionInFlight: Promise | null = null -/** - * Tracks the in-flight deleteSession request to dedupe concurrent calls. - */ -let deleteSessionInFlight: Promise | null = null - /** * Session cookie management for cloud authentication. * Creates and deletes session cookies on the ComfyUI server. @@ -23,40 +14,27 @@ export const useSessionCookie = () => { const createSession = async (): Promise => { if (!isCloud) return - if (createSessionInFlight) { - await createSessionInFlight - return + const authStore = useFirebaseAuthStore() + const authHeader = await authStore.getAuthHeader() + + if (!authHeader) { + throw new Error('No auth header available for session creation') } - createSessionInFlight = (async () => { - const authStore = useFirebaseAuthStore() - const authHeader = await authStore.getAuthHeader() - - if (!authHeader) { - throw new Error('No auth header available for session creation') + const response = await fetch(api.apiURL('/auth/session'), { + method: 'POST', + credentials: 'include', + headers: { + ...authHeader, + 'Content-Type': 'application/json' } + }) - const response = await fetch(api.apiURL('/auth/session'), { - method: 'POST', - credentials: 'include', - headers: { - ...authHeader, - 'Content-Type': 'application/json' - } - }) - - if (!response.ok) { - const errorData = await response.json().catch(() => ({})) - throw new Error( - `Failed to create session: ${errorData.message || response.statusText}` - ) - } - })() - - try { - await createSessionInFlight - } finally { - createSessionInFlight = null + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + throw new Error( + `Failed to create session: ${errorData.message || response.statusText}` + ) } } @@ -67,29 +45,16 @@ export const useSessionCookie = () => { const deleteSession = async (): Promise => { if (!isCloud) return - if (deleteSessionInFlight) { - await deleteSessionInFlight - return - } + const response = await fetch(api.apiURL('/auth/session'), { + method: 'DELETE', + credentials: 'include' + }) - deleteSessionInFlight = (async () => { - const response = await fetch(api.apiURL('/auth/session'), { - method: 'DELETE', - credentials: 'include' - }) - - if (!response.ok) { - const errorData = await response.json().catch(() => ({})) - throw new Error( - `Failed to delete session: ${errorData.message || response.statusText}` - ) - } - })() - - try { - await deleteSessionInFlight - } finally { - deleteSessionInFlight = null + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + throw new Error( + `Failed to delete session: ${errorData.message || response.statusText}` + ) } }