From f56af0cf4d521fc6e5d789ba7f3db5adc20f87c5 Mon Sep 17 00:00:00 2001 From: CD Cabrera Date: Thu, 16 Jul 2026 09:42:17 -0400 Subject: [PATCH 1/2] test: pf-4387 stdio client logging flake * e2e, stdio client logging, long-standing flake. related fetch updates make it consistent --- tests/e2e/utils/stdioTransportClient.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/e2e/utils/stdioTransportClient.ts b/tests/e2e/utils/stdioTransportClient.ts index 9b2965be..3bd63e8a 100644 --- a/tests/e2e/utils/stdioTransportClient.ts +++ b/tests/e2e/utils/stdioTransportClient.ts @@ -122,10 +122,17 @@ export const startServer = async ({ // Access stderr stream if available. stderr is used to prevent logs from interfering with JSON-RPC parsing // Collect server stderr logs const stderrLogs: string[] = []; + let logBuffer = ''; if (transport.stderr) { transport.stderr.on('data', (data: Buffer) => { - stderrLogs.push(data.toString()); + logBuffer += data.toString(); + const lines = logBuffer.split('\n'); + + logBuffer = lines.pop() || ''; + for (const line of lines) { + stderrLogs.push(`${line}\n`); + } }); } @@ -234,9 +241,13 @@ export const startServer = async ({ logs: () => [ ...stderrLogs, + ...(logBuffer ? [logBuffer] : []), ...protocolLogs ], - stderrLogs: () => stderrLogs.slice(), + stderrLogs: () => [ + ...stderrLogs, + ...(logBuffer ? [logBuffer] : []) + ], protocolLogs: () => protocolLogs.slice(), stop, close: stop // Alias for stop, align with the http transport client From 6a29339a5dc63ce73251e39a95a3563b2db8afb9 Mon Sep 17 00:00:00 2001 From: CD Cabrera Date: Thu, 16 Jul 2026 10:50:09 -0400 Subject: [PATCH 2/2] fix: review update --- tests/e2e/utils/stdioTransportClient.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/e2e/utils/stdioTransportClient.ts b/tests/e2e/utils/stdioTransportClient.ts index 3bd63e8a..0d218ca6 100644 --- a/tests/e2e/utils/stdioTransportClient.ts +++ b/tests/e2e/utils/stdioTransportClient.ts @@ -124,6 +124,15 @@ export const startServer = async ({ const stderrLogs: string[] = []; let logBuffer = ''; + /* + * Log streaming, partials are unavoidable. `stderr` gives us bytes, not lines. + * The returned `\n` from the writer is the only "line done" signal. We could attempt + * to wait for the `\n` and only return full completions, but we've opted to return + * the partials as they arrive. Basically, if you attempt to `equal` a log instead of + * using `contains` or `includes`, the test may fail, and you'll be disappointed. + * + * Subject to change; for now partials are returned as-is. + */ if (transport.stderr) { transport.stderr.on('data', (data: Buffer) => { logBuffer += data.toString();