stablyai/orca · error · Error
Could not reserve a guest port: ${result.stdout}
Error message
Could not reserve a guest port: ${result.stdout} What it means
Thrown by the WSL benchmark when a Python one-liner run inside the guest distro fails to print a usable ephemeral port number. The guest runs `socket.bind(('127.0.0.1',0))` and prints the assigned port; if stdout is non-numeric, zero, or empty, the host refuses to proceed because the relay needs a concrete port.
Source
Thrown at config/scripts/wsl-hook-relay-reattach-benchmark.mjs:122
function parseEndpoint(contents) {
const port = Number(/ORCA_AGENT_HOOK_PORT=['"]?(\d+)/.exec(contents)?.[1])
const token = /ORCA_AGENT_HOOK_TOKEN=['"]?([^'"\r\n]+)/.exec(contents)?.[1]
return Number.isInteger(port) && port > 0 && token ? { port, token } : null
}
async function freeGuestPort(distro) {
const result = await run(
'wsl.exe',
wslArgs(distro, [
'/usr/bin/python3',
'-c',
'import socket; s=socket.socket(); s.bind(("127.0.0.1",0)); print(s.getsockname()[1]); s.close()'
])
)
const port = Number(result.stdout.trim())
if (!Number.isInteger(port) || port <= 0) {
throw new Error(`Could not reserve a guest port: ${result.stdout}`)
}
return port
}
async function startStallingGuestServer(distro) {
const source = [
'import socket,sys,threading',
'stop=threading.Event()',
'threading.Thread(target=lambda:(sys.stdin.buffer.read(),stop.set()),daemon=True).start()',
'server=socket.socket()',
'server.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)',
'server.bind(("127.0.0.1",0))',
'server.listen()',
'server.settimeout(0.1)',
'print(f"READY {server.getsockname()[1]}",flush=True)',
'held=[]',
'while not stop.is_set():',
' try:',View on GitHub (pinned to 1136503c6a)
Solutions
- Install python3 in the WSL distro (apt-get install -y python3 or equivalent).
- Run the failing wsl.exe command manually to see the real stdout/stderr: `wsl.exe -d <distro> /usr/bin/python3 -c 'import socket; s=socket.socket(); s.bind(("127.0.0.1",0)); print(s.getsockname()[1]); s.close()'`.
- Confirm the distro name passed to resolveDistro is registered (`wsl.exe -l -q`).
- Consider a Node-based port reservation to drop the python3 dependency.
Example fix
// before
const port = Number(result.stdout.trim())
if (!Number.isInteger(port) || port <= 0) {
throw new Error(`Could not reserve a guest port: ${result.stdout}`)
}
// after — surface stderr too and check exit status
if (result.status !== 0) {
throw new Error(`Guest port probe failed (exit ${result.status}): ${result.stderr || result.stdout}`)
}
const port = Number(result.stdout.trim())
if (!Number.isInteger(port) || port <= 0) {
throw new Error(`Could not reserve a guest port: stdout=${JSON.stringify(result.stdout)} stderr=${JSON.stringify(result.stderr)}`)
} Defensive patterns
Strategy: validation
Validate before calling
// Pre-check python3 exists in the guest before relying on it
const probe = await run('wsl.exe', wslArgs(distro, ['/bin/sh', '-c', 'command -v python3 || exit 1']), { allowFailure: true })
if (probe.status !== 0) {
throw new Error(`python3 not found in distro ${distro}; install it before running the benchmark`)
} Type guard
function isPositivePortString(s: string): boolean {
const n = Number(s.trim())
return Number.isInteger(n) && n > 0 && n <= 65535
} Try / catch
try {
const port = await freeGuestPort(distro)
} catch (err) {
// Inspect result.stderr captured by run() to distinguish missing-python from a bind failure
throw err
} Prevention
- Document the python3 prerequisite in the benchmark README.
- Consider a Node-based port probe to drop the python dependency entirely.
- Always include stderr alongside stdout in reservation-failure messages.
When it happens
Trigger: python3 is missing or prints an error to stdout in the guest, the distro's PATH lacks /usr/bin/python3, WSL interop returns an error message instead of a port, or stdout has leading/trailing content that defeats Number()+trim().
Common situations: Minimal WSL images without python3 preinstalled, a distro where `python3` is actually a broken symlink, or wsl.exe returning an error string (e.g. distribution not registered) that lands in result.stdout.
Related errors
- Timed out waiting for ${description}
- This benchmark requires a Windows host with WSL
- WSL distro '${distro}' needs Node.js 18 or newer to run Orca
- Refusing to use an unexpected guest cleanup path
- advertised-url-watcher.ts no longer contains \`${marker}\`
AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12).
Data as JSON: /api/errors/cb43544493944e8c.
Report an issue: GitHub.