Files
ComfyUI_frontend/src/utils/errorReportUtil.ts
Christian Byrne 985d024a6e fix: handle non-string serverLogs in error report (#8460)
## Summary
- Fix `[object Object]` display in error report logs section

## Changes
- Add runtime type check for `serverLogs` in error report template
- JSON stringify object logs with proper formatting

## Test plan
- [x] Verify string logs still display correctly
- [x] Verify object logs are properly stringified instead of showing
`[object Object]`

Fixes https://github.com/Comfy-Org/ComfyUI_frontend/issues/8463

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-8460-fix-handle-non-string-serverLogs-in-error-report-2f86d73d36508179af5afcdeec025a75)
by [Unito](https://www.unito.io)

Co-authored-by: Subagent 5 <subagent@example.com>
2026-01-29 19:47:59 -08:00

81 lines
2.3 KiB
TypeScript

import type { ISerialisedGraph } from '@/lib/litegraph/src/litegraph'
import type { NodeId } from '@/platform/workflow/validation/schemas/workflowSchema'
import type { SystemStats } from '@/schemas/apiSchema'
export interface ErrorReportData {
exceptionType: string
exceptionMessage: string
systemStats: SystemStats
serverLogs: string
workflow: ISerialisedGraph
traceback?: string
nodeId?: NodeId
nodeType?: string
}
/**
* Generate a report for an error.
* @param error - The error to report.
* @returns The report.
*/
export function generateErrorReport(error: ErrorReportData): string {
// The default JSON workflow has about 3000 characters.
const MAX_JSON_LENGTH = 20000
const workflowJSONString = JSON.stringify(error.workflow)
const workflowText =
workflowJSONString.length > MAX_JSON_LENGTH
? 'Workflow too large. Please manually upload the workflow from local file system.'
: workflowJSONString
const systemStats = error.systemStats
return `
# ComfyUI Error Report
${
error
? `## Error Details
- **Node ID:** ${error.nodeId || 'N/A'}
- **Node Type:** ${error.nodeType || 'N/A'}
- **Exception Type:** ${error.exceptionType || 'N/A'}
- **Exception Message:** ${error.exceptionMessage || 'N/A'}
## Stack Trace
\`\`\`
${error.traceback || 'No stack trace available'}
\`\`\``
: ''
}
## 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(
(device) => `
- **Name:** ${device.name}
- **Type:** ${device.type}
- **VRAM Total:** ${device.vram_total}
- **VRAM Free:** ${device.vram_free}
- **Torch VRAM Total:** ${device.torch_vram_total}
- **Torch VRAM Free:** ${device.torch_vram_free}
`
)
.join('\n')}
## Logs
\`\`\`
${typeof error.serverLogs === 'string' ? error.serverLogs : JSON.stringify(error.serverLogs, null, 2)}
\`\`\`
## Attached Workflow
Please make sure that workflow does not contain any sensitive information such as API keys or passwords.
\`\`\`
${workflowText}
\`\`\`
## Additional Context
(Please add any additional context or steps to reproduce the error here)
`
}