Line data Source code
1 : import type { ISerialisedGraph } from '@/lib/litegraph/src/litegraph'
2 : import type { SystemStats } from '@comfyorg/api-client/types'
3 : import type { SerializedNodeId } from '@comfyorg/graph-model/nodeId'
4 :
5 : export interface ErrorReportData {
6 : exceptionType: string
7 : exceptionMessage: string
8 : systemStats: SystemStats
9 : serverLogs: string
10 : workflow: ISerialisedGraph
11 :
12 : traceback?: string
13 : nodeId?: SerializedNodeId
14 : nodeType?: string
15 : }
16 :
17 : /**
18 : * Generate a report for an error.
19 : * @param error - The error to report.
20 : * @returns The report.
21 : */
22 28 : export function generateErrorReport(error: ErrorReportData): string {
23 : // The default JSON workflow has about 3000 characters.
24 28 : const MAX_JSON_LENGTH = 20000
25 28 : const workflowJSONString = JSON.stringify(error.workflow)
26 28 : const workflowText =
27 : workflowJSONString.length > MAX_JSON_LENGTH
28 : ? 'Workflow too large. Please manually upload the workflow from local file system.'
29 : : workflowJSONString
30 28 : const systemStats = error.systemStats
31 :
32 28 : return `
33 : # ComfyUI Error Report
34 : ## Error Details
35 : - **Node ID:** ${error.nodeId || 'N/A'}
36 : - **Node Type:** ${error.nodeType || 'N/A'}
37 : - **Exception Type:** ${error.exceptionType || 'N/A'}
38 : - **Exception Message:** ${error.exceptionMessage || 'N/A'}
39 : ## Stack Trace
40 : \`\`\`
41 : ${error.traceback || 'No stack trace available'}
42 : \`\`\`
43 : ## System Information
44 : - **ComfyUI Version:** ${systemStats.system.comfyui_version}
45 : - **Arguments:** ${systemStats.system.argv.join(' ')}
46 : - **OS:** ${systemStats.system.os}
47 : - **Python Version:** ${systemStats.system.python_version}
48 : - **Embedded Python:** ${systemStats.system.embedded_python}
49 : - **PyTorch Version:** ${systemStats.system.pytorch_version}
50 : ## Devices
51 : ${systemStats.devices
52 : .map(
53 : (device) => `
54 : - **Name:** ${device.name}
55 : - **Type:** ${device.type}
56 : - **VRAM Total:** ${device.vram_total}
57 : - **VRAM Free:** ${device.vram_free}
58 : - **Torch VRAM Total:** ${device.torch_vram_total}
59 : - **Torch VRAM Free:** ${device.torch_vram_free}
60 : `
61 : )
62 : .join('\n')}
63 : ## Logs
64 : \`\`\`
65 : ${typeof error.serverLogs === 'string' ? error.serverLogs : JSON.stringify(error.serverLogs, null, 2)}
66 : \`\`\`
67 : ## Attached Workflow
68 : Please make sure that workflow does not contain any sensitive information such as API keys or passwords.
69 : \`\`\`
70 : ${workflowText}
71 : \`\`\`
72 :
73 : ## Additional Context
74 : (Please add any additional context or steps to reproduce the error here)
75 : `
76 : }
|