{"record":{"id":"49c5a9fcad0f861b","repo":"sgl-project/sglang","slug":"network-error-after-consecutive-errors-consecuti","errorCode":null,"errorMessage":"Network error after {consecutive_errors} consecutive failures: {str(e)}","messagePattern":"Network error after (.+?) consecutive failures: (.+?)","errorType":"error_code","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/server_api.py","lineNumber":348,"sourceCode":"                        error_msg = (\n                            error.get(\"message\", \"Unknown error\")\n                            if error\n                            else \"Unknown error\"\n                        )\n                        raise RuntimeError(f\"Video generation failed: {error_msg}\")\n                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,","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/server_api.py#L330-L366","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nresult = api.generate_video(prompt=p)  # Network error after N consecutive failures\n// after\nresult = api.generate_video(prompt=p, poll_interval=10, max_consecutive_errors=30)","handlingStrategy":"retry","validationCode":"api.generate_video(prompt=p, poll_interval=10, max_consecutive_errors=30)  # pre-tune budgets","typeGuard":null,"tryCatchPattern":"for attempt in range(2):\n    try:\n        return api.generate_video(prompt=p, poll_interval=10)\n    except RuntimeError as e:\n        if 'Network error after' not in str(e) or attempt: raise\n        time.sleep(10)","preventionTips":["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."],"tags":["network","timeout","video-generation","polling","retry","sgldiffusion"],"backgroundTag":"polling-timeout","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}