mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-06 13:40:25 +00:00
fix: prevent unwanted login redirects during WebSocket reconnection (#6410)
## 🐛 Problem Users were experiencing the following issues during WebSocket reconnection: 1. Automatic redirect to login page after "Reconnecting" toast message appears 2. Automatic re-login after a few seconds, returning to the main interface 3. This cycle repeats, severely degrading user experience ## 🔍 Root Cause Analysis ### 1. Router Guard Catching Too Many Errors ```typescript // Problematic code try { const { getUserCloudStatus, getSurveyCompletedStatus } = await import('@/api/auth') const userStatus = await getUserCloudStatus() // ... } catch (error) { // All types of errors are caught here return next({ name: 'cloud-user-check' }) } ``` With dynamic import inside the try block, the following were all being caught: - Errors during `@/api/auth` module loading - Runtime errors from the API singleton - Actual API call errors Everything was caught and redirected to `cloud-user-check`. ### 2. Full Page Reload in UserCheckView ```typescript // Problematic code window.location.href = '/' // Full page reload! ``` This caused: - Loss of SPA benefits - Firebase Auth re-initialization → temporarily null user - Router guard re-execution → potential for another redirect ## ✅ Solution ### 1. router.ts: Move dynamic import outside try block ```typescript // After fix const { getUserCloudStatus, getSurveyCompletedStatus } = await import('@/api/auth') try { // Only API calls inside try const userStatus = await getUserCloudStatus() // ... } catch (error) { // Now only catches pure API call errors return next({ name: 'cloud-user-check' }) } ``` ### 2. UserCheckView.vue: Use SPA routing ```typescript // After fix await router.replace('/') // Use Vue Router instead of window.location.href ``` 🤖 Generated with [Claude Code](https://claude.ai/code) ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6410-fix-prevent-unwanted-login-redirects-during-WebSocket-reconnection-29c6d73d3650818a8a1acbdcebd2f703) by [Unito](https://www.unito.io) --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { createSharedComposable } from '@vueuse/core'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
|
||||
import { useCurrentUser } from '@/composables/auth/useCurrentUser'
|
||||
import { useFirebaseAuthActions } from '@/composables/auth/useFirebaseAuthActions'
|
||||
|
||||
@@ -74,7 +74,7 @@ const {
|
||||
}
|
||||
|
||||
// User is fully onboarded
|
||||
window.location.href = '/'
|
||||
await router.replace('/')
|
||||
}),
|
||||
null,
|
||||
{ resetOnExecute: false }
|
||||
|
||||
Reference in New Issue
Block a user