sgl-project/sglang · error · TimeoutError
Video generation timed out after {max_wait_time} seconds
Error message
Video generation timed out after {max_wait_time} seconds What it means
TimeoutError raised by generate_video when the polling loop exceeds max_wait_time seconds without the job reaching a completed/failed state. The job may still be running server-side; only the client stopped waiting.
Source
Thrown at python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/server_api.py:354
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,
guidance_scale: Optional[float] = None,
num_inference_steps: Optional[int] = None,
seed: Optional[int] = None,
enable_teacache: bool = False,
background: Optional[str] = None,
output_format: Optional[str] = None,View on GitHub (pinned to 0132848349)
Solutions
- Pass a larger max_wait_time to generate_video for long jobs.
- Reduce the job cost: smaller size, fewer seconds, lower fps.
- Check the server queue to ensure the job is actually progressing rather than stuck.
- Note the job ID from logs and poll manually / retry if the server supports job resubmission.
Example fix
// before result = api.generate_video(prompt=p, seconds=10) # timed out after max_wait_time // after result = api.generate_video(prompt=p, seconds=10, max_wait_time=3600, poll_interval=10)
Defensive patterns
Strategy: retry
Validate before calling
estimated = seconds * (width * height) / 2_000_000 * 60 max_wait = max(600, int(estimated * 3)) # budget before submitting
Try / catch
try:
return api.generate_video(prompt=p, max_wait_time=3600)
except TimeoutError:
poll_job_status_manually(job_id) # job may still complete server-side Prevention
- Scale max_wait_time with resolution x duration.
- Shrink resolution/seconds when hitting timeouts.
- Persist the job id so a timeout doesn't lose the work.
When it happens
Trigger: Long video generations (high resolution, many seconds, slow hardware) that exceed the default max_wait_time; a stuck/queued job behind other work on the server.
Common situations: Default wait budget too small for 4K/multi-second videos; queued jobs waiting for GPU availability; server heavily loaded so each step is slow.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Network error after {consecutive_errors} consecutive failure
- Video generation failed: {error_msg}
- Lost connection to server after {consecutive_errors} consecu
- Failed to edit image: {str(e)}
- Failed to generate image: {str(e)}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/e39a2cb18bdc91d0.
Report an issue: GitHub.