mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
fix: add timeout guards to bootstrap initialization
Add AUTH_INIT_TIMEOUT (10s) to bootstrapStore's blocking until() waits for Firebase auth and user login, preventing indefinite hangs if auth initialization stalls. Wrap cloud init (remote config + telemetry) in try-catch so the app continues loading even if cloud services fail. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
14
src/main.ts
14
src/main.ts
@@ -28,12 +28,16 @@ import { i18n } from './i18n'
|
||||
const isCloud = __DISTRIBUTION__ === 'cloud'
|
||||
|
||||
if (isCloud) {
|
||||
const { refreshRemoteConfig } =
|
||||
await import('@/platform/remoteConfig/refreshRemoteConfig')
|
||||
await refreshRemoteConfig({ useAuth: false })
|
||||
try {
|
||||
const { refreshRemoteConfig } =
|
||||
await import('@/platform/remoteConfig/refreshRemoteConfig')
|
||||
await refreshRemoteConfig({ useAuth: false })
|
||||
|
||||
const { initTelemetry } = await import('@/platform/telemetry/initTelemetry')
|
||||
await initTelemetry()
|
||||
const { initTelemetry } = await import('@/platform/telemetry/initTelemetry')
|
||||
await initTelemetry()
|
||||
} catch (error) {
|
||||
console.warn('[init] Cloud initialization failed, continuing:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const ComfyUIPreset = definePreset(Aura, {
|
||||
|
||||
@@ -35,17 +35,20 @@ export const useBootstrapStore = defineStore('bootstrap', () => {
|
||||
void workflowStore.loadWorkflows()
|
||||
}
|
||||
|
||||
/** Maximum time to wait for auth initialization before proceeding */
|
||||
const AUTH_INIT_TIMEOUT = 10_000
|
||||
|
||||
async function startStoreBootstrap() {
|
||||
const userStore = useUserStore()
|
||||
await userStore.initialize()
|
||||
|
||||
if (isCloud) {
|
||||
const { isInitialized } = storeToRefs(useFirebaseAuthStore())
|
||||
await until(isInitialized).toBe(true)
|
||||
await until(isInitialized).toBe(true, { timeout: AUTH_INIT_TIMEOUT })
|
||||
}
|
||||
|
||||
const { needsLogin } = storeToRefs(userStore)
|
||||
await until(needsLogin).toBe(false)
|
||||
await until(needsLogin).toBe(false, { timeout: AUTH_INIT_TIMEOUT })
|
||||
|
||||
void loadI18n()
|
||||
loadAuthenticatedStores()
|
||||
|
||||
Reference in New Issue
Block a user