sgl-project/sglang · error · RuntimeError
Failed to generate image: {str(e)}
Error message
Failed to generate image: {str(e)} What it means
RuntimeError raised by the ComfyUI image node wrapping any exception from sgld_client.generate_image — network failures, server-side errors, or the upstream RuntimeErrors from server_api.py all surface here with their message chained.
Source
Thrown at python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/nodes.py:386
request_params["num_inference_steps"] = steps
if seed is not None and seed >= 0:
request_params["seed"] = seed
if enable_teacache:
request_params["enable_teacache"] = True
if image is not None:
# If the image is empty, use the size of the image to generate the image
if is_empty_image(image):
width, height = image.shape[2], image.shape[1]
size = f"{width}x{height}"
request_params["size"] = size
else:
request_params["image_path"] = get_image_path(image)
# Call API
try:
response = sgld_client.generate_image(**request_params)
except Exception as e:
raise RuntimeError(f"Failed to generate image: {str(e)}")
# Decode base64 image
if not response["data"] or not response["data"][0]["b64_json"]:
raise RuntimeError("No image data in response")
image_data = response["data"][0]["b64_json"]
image = convert_b64_to_tensor_image(image_data)
return (image,)
class SGLDiffusionGenerateVideo:
"""Node to generate videos using SGLang Diffusion."""
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"sgld_client": ("SGLD_CLIENT",),View on GitHub (pinned to 0132848349)
Solutions
- Read the chained message — it contains the true underlying cause (timeout, status code, etc.).
- Start/health-check the SGLang Diffusion server before running the workflow.
- Fix the underlying cause per its own error guidance (auth, params, timeout).
- Retry the workflow once the server is ready.
Defensive patterns
Strategy: try-catch
Validate before calling
import requests
assert requests.get(f"{sgld_client.base_url}/models", timeout=5).ok Try / catch
try:
out = node.generate_image(...)
except RuntimeError as e:
show_in_comfy_ui(str(e)) # chained message holds the real cause
raise Prevention
- Start and health-check the server before running workflows.
- Read chained cause messages before changing code.
- Retry once after model load completes.
When it happens
Trigger: Any failure of the underlying API call inside the node: server unreachable, generation error, or decode failure; the node re-raises as 'Failed to generate image: <cause>'.
Common situations: Server not running when the workflow executes; model still loading; bad api_key; generation parameters rejected by the server.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Failed to generate video: {str(e)}
- Failed to generate image: {str(e)}
- Prompt cannot be empty
- No image data in response
- Failed to get server info. {error_data['error']['message']}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/64dc4773ed79b06d.
Report an issue: GitHub.