{"record":{"id":"e39a2cb18bdc91d0","repo":"sgl-project/sglang","slug":"video-generation-timed-out-after-max-wait-time-s","errorCode":null,"errorMessage":"Video generation timed out after {max_wait_time} seconds","messagePattern":"Video generation timed out after (.+?) seconds","errorType":"error_code","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/server_api.py","lineNumber":354,"sourceCode":"                except requests.exceptions.ConnectionError as e:\n                    # Connection errors - likely server is down\n                    consecutive_errors += 1\n                    if consecutive_errors >= max_consecutive_errors:\n                        raise RuntimeError(\n                            f\"Lost connection to server after {consecutive_errors} consecutive errors. \"\n                            f\"Server may be unavailable: {str(e)}\"\n                        )\n                except requests.exceptions.RequestException as e:\n                    # Other network errors - continue polling but track errors\n                    consecutive_errors += 1\n                    if consecutive_errors >= max_consecutive_errors:\n                        raise RuntimeError(\n                            f\"Network error after {consecutive_errors} consecutive failures: {str(e)}\"\n                        )\n\n                time.sleep(poll_interval)\n\n            raise TimeoutError(\n                f\"Video generation timed out after {max_wait_time} seconds\"\n            )\n        except requests.exceptions.RequestException as e:\n            raise RuntimeError(f\"Failed to generate video: {str(e)}\")\n\n    def _build_image_common_params(\n        self,\n        prompt: str,\n        size: str,\n        n: int,\n        response_format: str,\n        negative_prompt: Optional[str] = None,\n        guidance_scale: Optional[float] = None,\n        num_inference_steps: Optional[int] = None,\n        seed: Optional[int] = None,\n        enable_teacache: bool = False,\n        background: Optional[str] = None,\n        output_format: Optional[str] = None,","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/server_api.py#L336-L372","documentation":"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.","triggerScenarios":"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.","commonSituations":"Default wait budget too small for 4K/multi-second videos; queued jobs waiting for GPU availability; server heavily loaded so each step is slow.","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."],"exampleFix":"// before\nresult = api.generate_video(prompt=p, seconds=10)  # timed out after max_wait_time\n// after\nresult = api.generate_video(prompt=p, seconds=10, max_wait_time=3600, poll_interval=10)","handlingStrategy":"retry","validationCode":"estimated = seconds * (width * height) / 2_000_000 * 60\nmax_wait = max(600, int(estimated * 3))  # budget before submitting","typeGuard":null,"tryCatchPattern":"try:\n    return api.generate_video(prompt=p, max_wait_time=3600)\nexcept TimeoutError:\n    poll_job_status_manually(job_id)  # job may still complete server-side","preventionTips":["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."],"tags":["timeout","video-generation","polling","sgldiffusion"],"backgroundTag":"async-job-timeout","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}