Comfy-Org/ComfyUI · error · Exception

Sonilo generation error ({code}): {message}

Error message

Sonilo generation error ({code}): {message}

What it means

Raised while consuming the Sonilo NDJSON event stream when an event of type "error" arrives. The stream itself is healthy (HTTP 200); the server reports an in-generation failure with a code and message which the node surfaces verbatim before any audio completes. Malformed JSON lines are skipped with a warning, so this only fires on well-formed error events.

Source

Thrown at comfy_api_nodes/nodes_sonilo.py:207

                raw_line = await resp.content.readline()
                if not raw_line:
                    break

                line = raw_line.decode("utf-8").strip()
                if not line:
                    continue

                try:
                    evt = json.loads(line)
                except json.JSONDecodeError:
                    logger.warning("Sonilo: skipping malformed NDJSON line")
                    continue

                evt_type = evt.get("type")
                if evt_type == "error":
                    code = evt.get("code", "UNKNOWN")
                    message = evt.get("message", "Unknown error")
                    raise Exception(f"Sonilo generation error ({code}): {message}")
                if evt_type == "duration":
                    duration_sec = evt.get("duration_sec")
                    if duration_sec is not None:
                        PromptServer.instance.send_progress_text(
                            f"Status: Generating\nVideo duration: {duration_sec:.1f}s",
                            node_id,
                        )
                elif evt_type in ("titles", "title"):
                    # v2m sends a "titles" list, t2m sends a scalar "title"
                    if evt_type == "titles":
                        titles = evt.get("titles", [])
                        if titles:
                            title = titles[0]
                    else:
                        title = evt.get("title") or title
                    if title:
                        PromptServer.instance.send_progress_text(
                            f"Status: Generating\nTitle: {title}",

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Read the code/message: content-related codes need a prompt change, quota codes need billing/top-up
  2. Retry once for transient internal errors (UNKNOWN/code not matching known categories)
  3. Check Sonilo account status and remaining credits
Defensive patterns

Strategy: try-catch

Try / catch

try:
    audio = await _sonilo_generate(...)
except Exception as e:
    msg = str(e)
    if "Sonilo generation error" in msg:
        code = msg.split("(")[1].split(")")[0]
        if code in ("QUOTA", "RATE_LIMIT"):
            schedule_retry_later()
        else:
            raise ValueError(f"Prompt rejected by Sonilo: {msg}") from e
    else:
        raise

Prevention

When it happens

Trigger: POST succeeds, streaming begins, and the server emits {"type":"error","code":...,"message":...} mid-stream — e.g. content policy rejection, internal model failure, or quota exhaustion during music generation.

Common situations: Prompt content rejected by Sonilo moderation; account quota/credits exhausted mid-request; Sonilo model-side errors occurring after queueing.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/e1e8e26eb2fcd14c. Report an issue: GitHub.