{"record":{"id":"9f4d99acdd57725d","repo":"zed-industries/zed","slug":"judge-proxy-exited-before-becoming-ready","errorCode":null,"errorMessage":"judge proxy exited before becoming ready","messagePattern":"judge proxy exited before becoming ready","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"crates/eval_cli/zed_eval/rejudge.py","lineNumber":189,"sourceCode":"            stdout=subprocess.DEVNULL,\n            stderr=subprocess.DEVNULL,\n        )\n        self._wait_for_port()\n        return self\n\n    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","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/eval_cli/zed_eval/rejudge.py#L171-L207","documentation":"During rejudging, rejudge.py spawns a local judge proxy subprocess and polls 127.0.0.1:<port> until it accepts TCP connections. _wait_for_port checks the process between probes; if the subprocess has already terminated (poll() returns a non-None exit code) before the port ever opened, it raises this RuntimeError. The proxy crashed at startup rather than being merely slow (slowness raises the sibling TimeoutError).","triggerScenarios":"Starting the rejudge flow when the proxy script exits immediately: missing dependency or PYTHONPATH, invalid model name or API key in the judge config, the target port already bound so the proxy aborts, or a syntax/version error in the proxy entrypoint.","commonSituations":"Rotated or missing judge API keys; a proxy update that requires a newer Python; a leftover proxy from a previous run still holding the port; config edits that renamed a required key.","solutions":["Run the proxy command manually with the same environment to see its traceback","Read the proxy log — the surrounding context manager captures and tails it on exit","Free the port if a stale proxy holds it: kill $(lsof -ti :<port>)","Verify judge config (model name, API key) and that the proxy's dependencies are installed"],"exampleFix":"# before\npython -m zed_eval.rejudge ...   # RuntimeError: judge proxy exited before becoming ready\n\n# after — reproduce the crash to see the real stderr\npython judge_proxy.py --port 8765   # fix the traceback it prints, then re-run rejudge","handlingStrategy":"try-catch","validationCode":"import socket\n\nwith socket.socket(socket.AF_INET, socket.SOCK_STREAM) as probe:\n    already_bound = probe.connect_ex((\"127.0.0.1\", port)) == 0\nif already_bound:\n    raise SystemExit(f\"port {port} already in use; a stale proxy may be running\")","typeGuard":null,"tryCatchPattern":"try:\n    with JudgeProxy(...) as proxy:\n        proxy.start()\nexcept RuntimeError as err:\n    if \"exited before becoming ready\" in str(err):\n        # the subprocess died: surface its log instead of retrying blindly\n        print(Path(\"/tmp/zed-judge-proxy.log\").read_text()[-2000:])\n    raise","preventionTips":["Run the proxy once manually after any config or dependency change","Kill stale proxies between rejudge runs","Fail fast on missing API keys at config load time, not at proxy start"],"tags":["subprocess","proxy","startup-crash","port","rejudge"],"backgroundTag":"process-exited-before-ready","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"}