From da1925cb67a1560e4d450a647b18db5f766608db Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Thu, 21 May 2026 23:54:33 +0800 Subject: [PATCH] test(e2e): isolate kitchen sink rpc gateway --- scripts/e2e/kitchen-sink-rpc-walk.mjs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/e2e/kitchen-sink-rpc-walk.mjs b/scripts/e2e/kitchen-sink-rpc-walk.mjs index 11c1b62259a..2c6ff2268ed 100644 --- a/scripts/e2e/kitchen-sink-rpc-walk.mjs +++ b/scripts/e2e/kitchen-sink-rpc-walk.mjs @@ -25,6 +25,7 @@ const COMMAND_TIMEOUT_MS = readPositiveInt( ); const RPC_TIMEOUT_MS = readPositiveInt(process.env.OPENCLAW_KITCHEN_SINK_RPC_CALL_MS, 60000); const MAX_RSS_MIB = readPositiveInt(process.env.OPENCLAW_KITCHEN_SINK_MAX_RSS_MIB, 2048); +const DEFAULT_PORT = 19000 + Math.floor(Math.random() * 1000); let callGatewayModulePromise; @@ -357,7 +358,7 @@ function startGateway(runner, port, env, logPath) { const child = childProcess.spawn(command.command, command.args, { ...command.options, env, - detached: false, + detached: process.platform !== "win32", }); fs.closeSync(log); return child; @@ -367,16 +368,26 @@ async function stopGateway(child) { if (!child || child.exitCode !== null) { return; } - child.kill("SIGTERM"); + signalGateway(child, "SIGTERM"); const started = Date.now(); while (child.exitCode === null && Date.now() - started < 10000) { await delay(100); } if (child.exitCode === null) { - child.kill("SIGKILL"); + signalGateway(child, "SIGKILL"); } } +function signalGateway(child, signal) { + if (process.platform !== "win32" && typeof child.pid === "number") { + try { + process.kill(-child.pid, signal); + return; + } catch {} + } + child.kill(signal); +} + async function waitForGatewayReady(child, port, logPath) { const started = Date.now(); let lastError = ""; @@ -555,7 +566,7 @@ function isNonEmptyString(value) { async function main() { const runner = resolveOpenClawRunner(); - const port = readPositiveInt(process.env.OPENCLAW_KITCHEN_SINK_RPC_PORT, 19173); + const port = readPositiveInt(process.env.OPENCLAW_KITCHEN_SINK_RPC_PORT, DEFAULT_PORT); const { root, env } = makeEnv(); const logPath = path.join(root, "gateway.log");