{"record":{"id":"9a0a36be43d09f24","repo":"zed-industries/zed","slug":"judge-proxy-did-not-open-port-self-port-in-time","errorCode":null,"errorMessage":"judge proxy did not open port {self._port} in time","messagePattern":"judge proxy did not open port (.+?) in time","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"crates/eval_cli/zed_eval/rejudge.py","lineNumber":195,"sourceCode":"    def __exit__(self, *_exc: object) -> None:\n        if self._process is not None:\n            self._process.terminate()\n            try:\n                self._process.wait(timeout=10)\n            except subprocess.TimeoutExpired:\n                self._process.kill()\n\n    def _wait_for_port(self, timeout_secs: float = 30.0) -> None:\n        deadline = time.time() + timeout_secs\n        while time.time() < deadline:\n            if self._process is not None and self._process.poll() is not None:\n                raise RuntimeError(\"judge proxy exited before becoming ready\")\n            with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as probe:\n                probe.settimeout(0.5)\n                if probe.connect_ex((\"127.0.0.1\", self._port)) == 0:\n                    return\n            time.sleep(0.25)\n        raise TimeoutError(f\"judge proxy did not open port {self._port} in time\")\n\n\ndef _stage_tests_dir(tests_dir: Path) -> None:\n    \"\"\"Point the absolute `/tests` path at this trial's package. Reset per trial\n    so each verifier reads its own rubrics/prompts.\"\"\"\n    if TESTS_DIR.is_symlink() or TESTS_DIR.exists():\n        if TESTS_DIR.is_dir() and not TESTS_DIR.is_symlink():\n            shutil.rmtree(TESTS_DIR)\n        else:\n            TESTS_DIR.unlink()\n    TESTS_DIR.symlink_to(tests_dir)\n\n\ndef _run_verifier(\n    part: str, tests_dir: Path, judge_model: str, port: int\n) -> dict[str, Any]:\n    \"\"\"Stage the verifier's expected inputs and run the real cached script.\"\"\"\n    LOGS_AGENT_DIR.mkdir(parents=True, exist_ok=True)","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/eval_cli/zed_eval/rejudge.py#L177-L213","documentation":"_wait_for_port gives the judge proxy a fixed 30-second window (probing every 250 ms) to start listening. If the deadline passes while the process is still alive but nothing accepts connections on 127.0.0.1:<port>, this TimeoutError is raised. The proxy is hung or slow, not crashed — a crash produces the sibling 'exited before becoming ready' RuntimeError instead.","triggerScenarios":"Calling rejudge when the proxy takes over 30 s to boot: cold-start model client initialization, dependency installation inside the proxy, DNS or credential lookups stalling, or a deadlock in the proxy before it binds the port.","commonSituations":"First run on a slow CI runner downloading packages; proxy waiting on a slow remote auth endpoint; containers with restricted loopback networking; heavily loaded machine running many trials in parallel.","solutions":["Pass a larger timeout_secs to _wait_for_port if startup is legitimately slow","Pre-install the proxy's dependencies in the image so startup fits the 30 s budget","Inspect the proxy log to see how far startup progressed","If it is hung rather than slow, add startup logging to the proxy or attach a debugger before bind()"],"exampleFix":"# before\nproxy._wait_for_port()  # TimeoutError: judge proxy did not open port 8765 in time\n\n# after\nproxy._wait_for_port(timeout_secs=120.0)","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"last_error = None\nfor attempt in range(3):\n    try:\n        proxy._wait_for_port(timeout_secs=30.0 * (attempt + 1))\n        break\n    except TimeoutError as err:\n        last_error = err\nelse:\n    raise last_error","preventionTips":["Pre-install the proxy's dependencies so startup fits the 30 s budget","Scale the timeout with machine slowness (CI vs laptop)","Distinguish from the 'exited before becoming ready' error: a live process means slow, a dead one means crash"],"tags":["timeout","proxy","port","startup","rejudge"],"backgroundTag":"service-startup-timeout","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}