zed-industries/zed · error · RuntimeError

judge proxy exited before becoming ready

Error message

judge proxy exited before becoming ready

What it means

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).

Solutions

  1. Run the proxy command manually with the same environment to see its traceback
  2. Read the proxy log — the surrounding context manager captures and tails it on exit
  3. Free the port if a stale proxy holds it: kill $(lsof -ti :<port>)
  4. Verify judge config (model name, API key) and that the proxy's dependencies are installed

Example fix

# before
python -m zed_eval.rejudge ...   # RuntimeError: judge proxy exited before becoming ready

# after — reproduce the crash to see the real stderr
python judge_proxy.py --port 8765   # fix the traceback it prints, then re-run rejudge
Defensive patterns

Strategy: try-catch

Validate before calling

import socket

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as probe:
    already_bound = probe.connect_ex(("127.0.0.1", port)) == 0
if already_bound:
    raise SystemExit(f"port {port} already in use; a stale proxy may be running")

Try / catch

try:
    with JudgeProxy(...) as proxy:
        proxy.start()
except RuntimeError as err:
    if "exited before becoming ready" in str(err):
        # the subprocess died: surface its log instead of retrying blindly
        print(Path("/tmp/zed-judge-proxy.log").read_text()[-2000:])
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/9f4d99acdd57725d. Report an issue: GitHub.

Appendix: source

Thrown at crates/eval_cli/zed_eval/rejudge.py:189

            stdout=subprocess.DEVNULL,
            stderr=subprocess.DEVNULL,
        )
        self._wait_for_port()
        return self

    def __exit__(self, *_exc: object) -> None:
        if self._process is not None:
            self._process.terminate()
            try:
                self._process.wait(timeout=10)
            except subprocess.TimeoutExpired:
                self._process.kill()

    def _wait_for_port(self, timeout_secs: float = 30.0) -> None:
        deadline = time.time() + timeout_secs
        while time.time() < deadline:
            if self._process is not None and self._process.poll() is not None:
                raise RuntimeError("judge proxy exited before becoming ready")
            with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as probe:
                probe.settimeout(0.5)
                if probe.connect_ex(("127.0.0.1", self._port)) == 0:
                    return
            time.sleep(0.25)
        raise TimeoutError(f"judge proxy did not open port {self._port} in time")


def _stage_tests_dir(tests_dir: Path) -> None:
    """Point the absolute `/tests` path at this trial's package. Reset per trial
    so each verifier reads its own rubrics/prompts."""
    if TESTS_DIR.is_symlink() or TESTS_DIR.exists():
        if TESTS_DIR.is_dir() and not TESTS_DIR.is_symlink():
            shutil.rmtree(TESTS_DIR)
        else:
            TESTS_DIR.unlink()
    TESTS_DIR.symlink_to(tests_dir)

View on GitHub (pinned to f4178619ac)