mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 19:21:54 +00:00
fix: replace vite preload error reload with error logging (#8261)
## Summary The reload approach didn't fully work because CSS and other preload errors emit different error types. Log errors for Sentry tracking instead, to be solved on the backend by serving chunks from past deployments. fix https://github.com/Comfy-Org/ComfyUI_frontend/issues/8153 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8261-fix-replace-vite-preload-error-reload-with-error-logging-2f16d73d365081e3b309f5470412506a) by [Unito](https://www.unito.io) --------- Co-authored-by: Alexander Brown <drjkl@comfy.org>
This commit is contained in:
31
src/App.vue
31
src/App.vue
@@ -9,6 +9,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { captureException } from '@sentry/vue'
|
||||||
import { useEventListener } from '@vueuse/core'
|
import { useEventListener } from '@vueuse/core'
|
||||||
import BlockUI from 'primevue/blockui'
|
import BlockUI from 'primevue/blockui'
|
||||||
import ProgressSpinner from 'primevue/progressspinner'
|
import ProgressSpinner from 'primevue/progressspinner'
|
||||||
@@ -16,10 +17,6 @@ import { computed, onMounted } from 'vue'
|
|||||||
|
|
||||||
import GlobalDialog from '@/components/dialog/GlobalDialog.vue'
|
import GlobalDialog from '@/components/dialog/GlobalDialog.vue'
|
||||||
import config from '@/config'
|
import config from '@/config'
|
||||||
import { t } from '@/i18n'
|
|
||||||
import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
|
|
||||||
import { app } from '@/scripts/app'
|
|
||||||
import { useDialogService } from '@/services/dialogService'
|
|
||||||
import { useWorkspaceStore } from '@/stores/workspaceStore'
|
import { useWorkspaceStore } from '@/stores/workspaceStore'
|
||||||
import { useConflictDetection } from '@/workbench/extensions/manager/composables/useConflictDetection'
|
import { useConflictDetection } from '@/workbench/extensions/manager/composables/useConflictDetection'
|
||||||
|
|
||||||
@@ -27,8 +24,6 @@ import { electronAPI, isElectron } from './utils/envUtil'
|
|||||||
|
|
||||||
const workspaceStore = useWorkspaceStore()
|
const workspaceStore = useWorkspaceStore()
|
||||||
const conflictDetection = useConflictDetection()
|
const conflictDetection = useConflictDetection()
|
||||||
const workflowStore = useWorkflowStore()
|
|
||||||
const dialogService = useDialogService()
|
|
||||||
const isLoading = computed<boolean>(() => workspaceStore.spinner)
|
const isLoading = computed<boolean>(() => workspaceStore.spinner)
|
||||||
const handleKey = (e: KeyboardEvent) => {
|
const handleKey = (e: KeyboardEvent) => {
|
||||||
workspaceStore.shiftDown = e.shiftKey
|
workspaceStore.shiftDown = e.shiftKey
|
||||||
@@ -54,23 +49,15 @@ onMounted(() => {
|
|||||||
document.addEventListener('contextmenu', showContextMenu)
|
document.addEventListener('contextmenu', showContextMenu)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle Vite preload errors (e.g., when assets are deleted after deployment)
|
window.addEventListener('vite:preloadError', (event) => {
|
||||||
window.addEventListener('vite:preloadError', async (_event) => {
|
event.preventDefault()
|
||||||
// Auto-reload if app is not ready or there are no unsaved changes
|
// eslint-disable-next-line no-undef
|
||||||
if (!app.vueAppReady || !workflowStore.activeWorkflow?.isModified) {
|
if (__DISTRIBUTION__ === 'cloud') {
|
||||||
window.location.reload()
|
captureException(event.payload, {
|
||||||
|
tags: { error_type: 'vite_preload_error' }
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
// Show confirmation dialog if there are unsaved changes
|
console.error('[vite:preloadError]', event.payload)
|
||||||
await dialogService
|
|
||||||
.confirm({
|
|
||||||
title: t('g.vitePreloadErrorTitle'),
|
|
||||||
message: t('g.vitePreloadErrorMessage')
|
|
||||||
})
|
|
||||||
.then((confirmed) => {
|
|
||||||
if (confirmed) {
|
|
||||||
window.location.reload()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -43,8 +43,6 @@
|
|||||||
"comfy": "Comfy",
|
"comfy": "Comfy",
|
||||||
"refresh": "Refresh",
|
"refresh": "Refresh",
|
||||||
"refreshNode": "Refresh Node",
|
"refreshNode": "Refresh Node",
|
||||||
"vitePreloadErrorTitle": "New Version Available",
|
|
||||||
"vitePreloadErrorMessage": "A new version of the app has been released. Would you like to reload?\nIf not, some parts of the app might not work as expected.\nFeel free to decline and save your progress before reloading.",
|
|
||||||
"terminal": "Terminal",
|
"terminal": "Terminal",
|
||||||
"logs": "Logs",
|
"logs": "Logs",
|
||||||
"videoFailedToLoad": "Video failed to load",
|
"videoFailedToLoad": "Video failed to load",
|
||||||
|
|||||||
Reference in New Issue
Block a user