From f42609c966a1174d7ecdde718ce25483553de0e7 Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Thu, 29 Aug 2024 21:29:33 -0400 Subject: [PATCH] Add support for extra system stats in error report (#684) * Add support for extra system stats in error report * Add toast on error --- .../content/ExecutionErrorDialogContent.vue | 26 ++++++++++++++++--- src/scripts/api.ts | 9 +++++++ src/types/apiTypes.ts | 5 +++- vite.config.mts | 3 +++ 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/components/dialog/content/ExecutionErrorDialogContent.vue b/src/components/dialog/content/ExecutionErrorDialogContent.vue index 98f58a688..09f28a09d 100644 --- a/src/components/dialog/content/ExecutionErrorDialogContent.vue +++ b/src/components/dialog/content/ExecutionErrorDialogContent.vue @@ -70,10 +70,24 @@ const toast = useToast() const { copy, isSupported } = useClipboard() onMounted(async () => { - generateReport(await api.getSystemStats()) + try { + const [systemStats, logs] = await Promise.all([ + api.getSystemStats(), + api.getLogs() + ]) + generateReport(systemStats, logs) + } catch (error) { + console.error('Error fetching system stats or logs:', error) + toast.add({ + severity: 'error', + summary: 'Error', + detail: 'Failed to fetch system information', + life: 5000 + }) + } }) -const generateReport = (systemStats: SystemStats) => { +const generateReport = (systemStats: SystemStats, logs: string) => { // The default JSON workflow has about 3000 characters. const MAX_JSON_LENGTH = 20000 const workflowJSONString = JSON.stringify(app.graph.serialize()) @@ -93,9 +107,12 @@ const generateReport = (systemStats: SystemStats) => { ${props.error.traceback.join('\n')} \`\`\` ## System Information +- **ComfyUI Version:** ${systemStats.system.comfyui_version} +- **Arguments:** ${systemStats.system.argv.join(' ')} - **OS:** ${systemStats.system.os} - **Python Version:** ${systemStats.system.python_version} - **Embedded Python:** ${systemStats.system.embedded_python} +- **PyTorch Version:** ${systemStats.system.pytorch_version} ## Devices ${systemStats.devices .map( @@ -109,7 +126,10 @@ ${systemStats.devices ` ) .join('\n')} - +## Logs +\`\`\` +${logs} +\`\`\` ## Attached Workflow Please make sure that workflow does not contain any sensitive information such as API keys or passwords. \`\`\` diff --git a/src/scripts/api.ts b/src/scripts/api.ts index 11da47abb..868a15042 100644 --- a/src/scripts/api.ts +++ b/src/scripts/api.ts @@ -13,6 +13,7 @@ import { User, Settings } from '@/types/apiTypes' +import axios from 'axios' interface QueuePromptRequestBody { client_id: string @@ -46,6 +47,10 @@ class ComfyApi extends EventTarget { this.initialClientId = sessionStorage.getItem('clientId') } + internalURL(route: string): string { + return this.api_base + '/internal' + route + } + apiURL(route: string): string { return this.api_base + '/api' + route } @@ -652,6 +657,10 @@ class ComfyApi extends EventTarget { } return resp.json() } + + async getLogs(): Promise { + return (await axios.get(this.internalURL('/logs'))).data + } } export const api = new ComfyApi() diff --git a/src/types/apiTypes.ts b/src/types/apiTypes.ts index ac4a0f9d5..799951ea0 100644 --- a/src/types/apiTypes.ts +++ b/src/types/apiTypes.ts @@ -389,7 +389,10 @@ export const zSystemStats = z.object({ system: z.object({ os: z.string(), python_version: z.string(), - embedded_python: z.boolean() + embedded_python: z.boolean(), + comfyui_version: z.string(), + pytorch_version: z.string(), + argv: z.array(z.string()) }), devices: z.array( z.object({ diff --git a/vite.config.mts b/vite.config.mts index fd607a495..4181fb681 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -91,6 +91,9 @@ export default defineConfig({ base: '', server: { proxy: { + '/internal': { + target: DEV_SERVER_COMFYUI_URL, + }, '/api': { target: DEV_SERVER_COMFYUI_URL, // Return empty array for extensions API as these modules