From 995d7e5342c9794c8e73a94a0544b879ab4cba71 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Thu, 8 Oct 2026 16:24:51 +0800 Subject: [PATCH] Keep NUL bytes out of the build-agent log test output Two build-agent log tests flood record() with NUL-only lines. record() mirrors every line to process.stderr, so each run printed about 66,000 NUL bytes into the platform-unit output. In CI these showed up as thousands of ^@ lines and buried the real failure. Stub process.stderr.write only around the two NUL loops. The tests check the log ring and the /logs body, never stderr, so what they assert does not change. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../api/test/unit/build-manager.test.ts | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/platform/packages/api/test/unit/build-manager.test.ts b/platform/packages/api/test/unit/build-manager.test.ts index fd30a188b..94bd7a566 100644 --- a/platform/packages/api/test/unit/build-manager.test.ts +++ b/platform/packages/api/test/unit/build-manager.test.ts @@ -7174,8 +7174,14 @@ describe('build-agent GET /logs serves post-child-close lines', () => { // is just under the 2 MiB budget, and the line cap is 2000). Serialized, each // NUL is `\u0000` — six bytes — so the real body is ~12.6 MB. const control = '\u0000'.repeat(1048); - for (let i = 0; i < MAX_LOG_RESPONSE_LINES; i++) { - record(control, 'stdout'); + // record() mirrors each line to stderr; keep the NUL bytes out of the test output. + const mirror = vi.spyOn(process.stderr, 'write').mockReturnValue(true); + try { + for (let i = 0; i < MAX_LOG_RESPONSE_LINES; i++) { + record(control, 'stdout'); + } + } finally { + mirror.mockRestore(); } server = await startControlServer(0); @@ -7735,8 +7741,14 @@ describe('build-agent log buffer is bounded', () => { const control = '\u0000'.repeat(64 * 1024); const flood = Math.ceil((MAX_BUFFERED_LOG_BYTES / (control.length * 6)) * 2); expect(flood).toBeLessThan(MAX_BUFFERED_LOG_LINES); - for (let i = 0; i < flood; i += 1) { - record(control, 'stdout'); + // record() mirrors each line to stderr; keep the NUL bytes out of the test output. + const mirror = vi.spyOn(process.stderr, 'write').mockReturnValue(true); + try { + for (let i = 0; i < flood; i += 1) { + record(control, 'stdout'); + } + } finally { + mirror.mockRestore(); } const wire = getBufferedLogLines().reduce(