sgl-project/sglang · error · RuntimeError
Network error after {consecutive_errors} consecutive failure
Error message
Network error after {consecutive_errors} consecutive failures: {str(e)} What it means
RuntimeError raised in generate_video when non-ConnectionError requests exceptions (timeouts, protocol errors, etc.) accumulate to max_consecutive_errors during status polling. The loop tolerates individual transient errors but gives up after the budget is spent.
Source
Thrown at python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/server_api.py:348
error_msg = (
error.get("message", "Unknown error")
if error
else "Unknown error"
)
raise RuntimeError(f"Video generation failed: {error_msg}")
except requests.exceptions.ConnectionError as e:
# Connection errors - likely server is down
consecutive_errors += 1
if consecutive_errors >= max_consecutive_errors:
raise RuntimeError(
f"Lost connection to server after {consecutive_errors} consecutive errors. "
f"Server may be unavailable: {str(e)}"
)
except requests.exceptions.RequestException as e:
# Other network errors - continue polling but track errors
consecutive_errors += 1
if consecutive_errors >= max_consecutive_errors:
raise RuntimeError(
f"Network error after {consecutive_errors} consecutive failures: {str(e)}"
)
time.sleep(poll_interval)
raise TimeoutError(
f"Video generation timed out after {max_wait_time} seconds"
)
except requests.exceptions.RequestException as e:
raise RuntimeError(f"Failed to generate video: {str(e)}")
def _build_image_common_params(
self,
prompt: str,
size: str,
n: int,
response_format: str,
negative_prompt: Optional[str] = None,View on GitHub (pinned to 0132848349)
Solutions
- Increase the per-request timeout and/or poll_interval passed to generate_video.
- If a proxy sits in front, raise its read timeout for the status endpoint.
- Check server health/logs to see why responses are failing.
- Raise max_consecutive_errors to ride out transient bursts.
Example fix
// before result = api.generate_video(prompt=p) # Network error after N consecutive failures // after result = api.generate_video(prompt=p, poll_interval=10, max_consecutive_errors=30)
Defensive patterns
Strategy: retry
Validate before calling
api.generate_video(prompt=p, poll_interval=10, max_consecutive_errors=30) # pre-tune budgets
Try / catch
for attempt in range(2):
try:
return api.generate_video(prompt=p, poll_interval=10)
except RuntimeError as e:
if 'Network error after' not in str(e) or attempt: raise
time.sleep(10) Prevention
- Use a poll_interval of 5-10s, not sub-second.
- Raise proxy read timeouts for status endpoints.
- Size max_consecutive_errors to expected transient bursts.
When it happens
Trigger: Poll requests repeatedly timing out (per-request timeout too small for a busy server) or malformed responses for the whole consecutive-error budget while the job polls.
Common situations: Server so busy generating that poll responses are slow; reverse proxy with aggressive timeouts between client and server; poll_interval too aggressive hammering the server.
Related errors
- Failed to generate image: {str(e)}
- Lost connection to server after {consecutive_errors} consecu
- Video generation timed out after {max_wait_time} seconds
- Failed to edit image: {str(e)}
- Video generation failed: {error_msg}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/49c5a9fcad0f861b.
Report an issue: GitHub.