From c40d2c45bfe2cb53d6cc9ea30f08eda74c791de2 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 7 Jun 2026 04:26:55 +0200 Subject: [PATCH] fix(e2e): honor kitchen sink output caps --- scripts/e2e/kitchen-sink-rpc-walk.mjs | 6 ++++-- test/scripts/kitchen-sink-rpc-walk.test.ts | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/scripts/e2e/kitchen-sink-rpc-walk.mjs b/scripts/e2e/kitchen-sink-rpc-walk.mjs index 339e33cb58cc..d2ba3f22d2bd 100644 --- a/scripts/e2e/kitchen-sink-rpc-walk.mjs +++ b/scripts/e2e/kitchen-sink-rpc-walk.mjs @@ -245,6 +245,7 @@ export function runCommand(command, args, options = {}) { resourceSampleIntervalMs = 1000, resourceSampleOptions, resourceSamples, + outputCaptureChars = config.outputCaptureChars, requireResourceSample = false, sampleProcessImpl = sampleProcess, timeoutKillGraceMs = 2000, @@ -318,10 +319,10 @@ export function runCommand(command, args, options = {}) { forceKillTimer.unref(); }, timeoutMs); child.stdout?.on("data", (chunk) => { - stdout = appendBoundedOutput(stdout, chunk); + stdout = appendBoundedOutput(stdout, chunk, outputCaptureChars); }); child.stderr?.on("data", (chunk) => { - stderr = appendBoundedOutput(stderr, chunk); + stderr = appendBoundedOutput(stderr, chunk, outputCaptureChars); }); child.on("error", (error) => { clearTimeout(timer); @@ -395,6 +396,7 @@ async function runOpenClaw(runner, args, env, options = {}) { resourceSampleIntervalMs: options.resourceSampleIntervalMs, resourceSampleOptions: options.resourceSampleOptions, resourceSamples: options.resourceSamples, + outputCaptureChars: config.outputCaptureChars, requireResourceSample: options.requireResourceSample, timeoutMs: options.timeoutMs ?? config.commandTimeoutMs, }); diff --git a/test/scripts/kitchen-sink-rpc-walk.test.ts b/test/scripts/kitchen-sink-rpc-walk.test.ts index 7d9ef3630833..12debc282854 100644 --- a/test/scripts/kitchen-sink-rpc-walk.test.ts +++ b/test/scripts/kitchen-sink-rpc-walk.test.ts @@ -462,6 +462,21 @@ describe("kitchen-sink RPC command output capture", () => { expect(second).toEqual({ text: "fghij", truncatedChars: 5 }); }); + it("honors the resolved command output capture limit", async () => { + const result = await runCommand( + process.execPath, + ["-e", "process.stdout.write('abcdef'); process.stderr.write('UVWXYZ');"], + { + outputCaptureChars: 3, + }, + ); + + expect(result.stdout).toBe("def"); + expect(result.stderr).toBe("XYZ"); + expect(result.stdoutTruncatedChars).toBe(3); + expect(result.stderrTruncatedChars).toBe(3); + }); + posixIt("kills timed command process groups", async () => { const root = mkdtempSync(path.join(tmpdir(), "openclaw-kitchen-rpc-timeout-")); const scriptPath = path.join(root, "trap-term.mjs");