From 0303d9077f5df56f02c6eaf24b8acb41a52dee95 Mon Sep 17 00:00:00 2001 From: Comfy Org PR Bot Date: Fri, 7 Nov 2025 15:15:46 +0900 Subject: [PATCH] [backport rh-test] fix: Handle vite:preloadError for graceful deployment asset updates (#6616) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backport of #6609 to `rh-test` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6616-backport-rh-test-fix-Handle-vite-preloadError-for-graceful-deployment-asset-updates-2a36d73d365081ba813fca8d72492cac) by [Unito](https://www.unito.io) Co-authored-by: Jin Yi --- src/App.vue | 26 ++++++++++++++++++++++++++ src/locales/en/main.json | 2 ++ 2 files changed, 28 insertions(+) diff --git a/src/App.vue b/src/App.vue index c0c9fdd20..642649f64 100644 --- a/src/App.vue +++ b/src/App.vue @@ -16,6 +16,10 @@ import { computed, onMounted } from 'vue' import GlobalDialog from '@/components/dialog/GlobalDialog.vue' 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 { useConflictDetection } from '@/workbench/extensions/manager/composables/useConflictDetection' @@ -23,6 +27,8 @@ import { electronAPI, isElectron } from './utils/envUtil' const workspaceStore = useWorkspaceStore() const conflictDetection = useConflictDetection() +const workflowStore = useWorkflowStore() +const dialogService = useDialogService() const isLoading = computed(() => workspaceStore.spinner) const handleKey = (e: KeyboardEvent) => { workspaceStore.shiftDown = e.shiftKey @@ -49,6 +55,26 @@ onMounted(() => { document.addEventListener('contextmenu', showContextMenu) } + // Handle Vite preload errors (e.g., when assets are deleted after deployment) + window.addEventListener('vite:preloadError', async (_event) => { + // Auto-reload if app is not ready or there are no unsaved changes + if (!app.vueAppReady || !workflowStore.activeWorkflow?.isModified) { + window.location.reload() + } else { + // Show confirmation dialog if there are unsaved changes + await dialogService + .confirm({ + title: t('g.vitePreloadErrorTitle'), + message: t('g.vitePreloadErrorMessage') + }) + .then((confirmed) => { + if (confirmed) { + window.location.reload() + } + }) + } + }) + // Initialize conflict detection in background // This runs async and doesn't block UI setup void conflictDetection.initializeConflictDetection() diff --git a/src/locales/en/main.json b/src/locales/en/main.json index 66be74d9b..6787d83cc 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -27,6 +27,8 @@ "logoAlt": "ComfyUI Logo", "refresh": "Refresh", "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", "logs": "Logs", "videoFailedToLoad": "Video failed to load",