Gateway: harden Compose-style gateway port parsing

This commit is contained in:
Kwanghee Park (hugh.k)
2026-03-12 22:48:14 +09:00
committed by Peter Steinberger
parent b665749e9f
commit ac7ca52090
6 changed files with 75 additions and 51 deletions

View File

@@ -3,8 +3,7 @@ import { spawnSync } from "node:child_process";
import os from "node:os";
import path from "node:path";
import { forceFreePort, type PortProcess } from "../src/cli/ports.js";
const DEFAULT_PORT = 18789;
import { resolveGatewayPort } from "../src/config/config.js";
function killGatewayListeners(port: number): PortProcess[] {
try {
@@ -44,7 +43,7 @@ function runTests() {
}
function main() {
const port = Number.parseInt(process.env.OPENCLAW_GATEWAY_PORT ?? `${DEFAULT_PORT}`, 10);
const port = resolveGatewayPort(undefined, process.env);
console.log(`🧹 test:force - clearing gateway on port ${port}`);
const killed = killGatewayListeners(port);