Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions src/stores/bootstrapStore.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { until, useAsyncState } from '@vueuse/core'
import { defineStore, storeToRefs } from 'pinia'

import { isCloud } from '@/platform/distribution/types'
import { useSettingStore } from '@/platform/settings/settingStore'
import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
import { api } from '@/scripts/api'
import { useUserStore } from '@/stores/userStore'
import { isCloud } from '@/platform/distribution/types'
import { useFirebaseAuthStore } from '@/stores/firebaseAuthStore'
import { useUserStore } from '@/stores/userStore'

export const useBootstrapStore = defineStore('bootstrap', () => {
const settingStore = useSettingStore()
Expand All @@ -26,9 +26,16 @@ export const useBootstrapStore = defineStore('bootstrap', () => {
{ immediate: false }
)

let storesLoaded = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gasp


function loadAuthenticatedStores() {
if (storesLoaded) return
storesLoaded = true
void settingStore.load()
void workflowStore.loadWorkflows()
}

async function startStoreBootstrap() {
// Defer settings and workflows if multi-user login is required
// (settings API requires authentication in multi-user mode)
const userStore = useUserStore()
await userStore.initialize()

Expand All @@ -37,13 +44,11 @@ export const useBootstrapStore = defineStore('bootstrap', () => {
await until(isInitialized).toBe(true)
}

// i18n can load without authentication
void loadI18n()
const { needsLogin } = storeToRefs(userStore)
await until(needsLogin).toBe(false)

if (!userStore.needsLogin) {
void settingStore.load()
void workflowStore.loadWorkflows()
}
void loadI18n()
loadAuthenticatedStores()
Comment on lines +47 to +51
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# First, get the repository structure overview
echo "=== Repository structure ==="
find . -type f -name "*.ts" -path "*store*" | grep -E "(bootstrap|user)" | head -20

echo ""
echo "=== Check bootstrapStore.ts content ==="
cat -n src/stores/bootstrapStore.ts | head -80

Repository: Comfy-Org/ComfyUI_frontend

Length of output: 2313


🏁 Script executed:

#!/bin/bash
# Check userStore implementation
echo "=== Check userStore.ts for needsLogin ==="
fd "userStore.ts$" --exec cat -n {} \;

echo ""
echo "=== Search for needsLogin usage pattern ==="
rg "needsLogin" -n -C3 --type ts

Repository: Comfy-Org/ComfyUI_frontend

Length of output: 5395


🏁 Script executed:

#!/bin/bash
# Check how startStoreBootstrap is called and used
echo "=== Check startStoreBootstrap usage ==="
rg "startStoreBootstrap" -n -B2 -A2 --type ts --type vue

echo ""
echo "=== Check if bootstrap completion is awaited in App.vue or main.ts ==="
rg -n "bootstrap|isI18nReady|needsLogin" src/App.vue src/main.ts --type vue --type ts 2>/dev/null | head -30

Repository: Comfy-Org/ComfyUI_frontend

Length of output: 226


🏁 Script executed:

#!/bin/bash
# Check if there's a timeout mechanism in the bootstrap flow
echo "=== Search for timeout in bootstrap or until usage ==="
rg "until.*toBe|timeout|abortSignal" -n --type ts | grep -E "(bootstrap|until|timeout)"

echo ""
echo "=== Check the 'until' function import ==="
rg "import.*until" -n --type ts

Repository: Comfy-Org/ComfyUI_frontend

Length of output: 15501


🏁 Script executed:

#!/bin/bash
# Understand the user authentication flow
echo "=== Check user initialization and login flow ==="
rg "initialize|needsLogin.*true|needsLogin.*false|setNeedsLogin" -n -C2 --type ts | head -50

Repository: Comfy-Org/ComfyUI_frontend

Length of output: 4777


🏁 Script executed:

#!/bin/bash
# Search for startStoreBootstrap invocation
echo "=== Searching for startStoreBootstrap calls ==="
rg "startStoreBootstrap" -n --type ts --type vue

echo ""
echo "=== Check App initialization in main files ==="
fd -e ts -e vue "main\.(ts|vue)$|App\.(ts|vue)$" | head -10 | xargs -I {} bash -c 'echo "=== {} ===" && head -50 {}'

Repository: Comfy-Org/ComfyUI_frontend

Length of output: 4777


🏁 Script executed:

#!/bin/bash
# Check if bootstrap is awaited at application startup
echo "=== Search for bootstrap in entry points ==="
find . -name "main.ts" -o -name "main.js" | xargs cat 2>/dev/null | head -100

echo ""
echo "=== Check vite.config or entry points ==="
find . \( -name "vite.config.*" -o -name "tsconfig.json" \) -exec grep -l "entry\|src/main" {} \;

Repository: Comfy-Org/ComfyUI_frontend

Length of output: 3380


🏁 Script executed:

#!/bin/bash
# Look at App.vue setup
echo "=== Check App.vue or root component ==="
find src -name "App.vue" -o -name "App.ts" | xargs cat 2>/dev/null | head -100

Repository: Comfy-Org/ComfyUI_frontend

Length of output: 2133


🏁 Script executed:

#!/bin/bash
# Search for router guards and how bootstrap is used
echo "=== Check router.ts for bootstrap usage ==="
cat -n src/router.ts | head -200

echo ""
echo "=== Search specifically for bootstrap in router ==="
rg "bootstrap|startStoreBootstrap" src/router.ts -n -A3 -B3

Repository: Comfy-Org/ComfyUI_frontend

Length of output: 7292


🏁 Script executed:

#!/bin/bash
# Check if bootstrap is called in beforeEach or other router hooks
echo "=== Full router.ts ==="
wc -l src/router.ts && echo "File is large, checking structure..." && grep -n "beforeEach\|startStoreBootstrap\|Bootstrap" src/router.ts

Repository: Comfy-Org/ComfyUI_frontend

Length of output: 200


🏁 Script executed:

#!/bin/bash
# Get full main.ts content
echo "=== Full main.ts content ==="
cat -n src/main.ts

Repository: Comfy-Org/ComfyUI_frontend

Length of output: 3541


🏁 Script executed:

#!/bin/bash
# Search more broadly for useBootstrapStore usage
echo "=== Search for useBootstrapStore usage ==="
rg "useBootstrapStore" -n --type ts

echo ""
echo "=== Check if bootstrap is referenced anywhere ==="
rg "startStoreBootstrap|useBootstrapStore" -r . --type ts

Repository: Comfy-Org/ComfyUI_frontend

Length of output: 1386


🏁 Script executed:

#!/bin/bash
# Verify the until function signature and confirm no default timeout
echo "=== Check VueUse documentation for until() ==="
rg "from '@vueuse/core'" -A5 src/router.ts src/stores/bootstrapStore.ts

echo ""
echo "=== Check if there's any error handling around the until() call ==="
cat -n src/stores/bootstrapStore.ts | sed -n '38,52p'

Repository: Comfy-Org/ComfyUI_frontend

Length of output: 1399


Add timeout to until(needsLogin).toBe(false) to prevent indefinite blocking.

The await until(needsLogin).toBe(false) on line 48 lacks a timeout and will hang indefinitely if the user is on a multi-user server and hasn't logged in yet (making needsLogin remain true). This blocks loadI18n() and loadAuthenticatedStores() from completing.

Add a timeout parameter matching the pattern used in src/router.ts:141:

await until(needsLogin).toBe(false, { timeout: 16_000 })

The same issue exists on line 44 for Firebase auth initialization in cloud mode—both until() calls should have explicit timeouts with appropriate error handling.

🤖 Prompt for AI Agents
In `@src/stores/bootstrapStore.ts` around lines 47 - 51, Add explicit timeouts to
the blocking until(...) calls: change the Firebase auth initialization wait (the
until(...).toBe(...) used in cloud mode) and the await
until(needsLogin).toBe(false) to include a timeout option (e.g., { timeout:
16_000 }) and wrap each await in try/catch so a timeout doesn't indefinitely
block startup; in the catch log a clear error/warning and allow execution to
continue so functions like loadI18n() and loadAuthenticatedStores() still run.

}

return {
Expand Down
Loading