Skip to content

Keep NUL bytes out of the build-agent log test output - #392

Merged
Brooooooklyn merged 1 commit into
mainfrom
fix/platform-unit-nul-output
Oct 8, 2026
Merged

Brooooooklyn merged 1 commit into
mainfrom
fix/platform-unit-nul-output

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Member

Problem

When test (platform-unit) fails in CI, the log hides the failure under thousands of ^@ lines.

build-manager.test.ts
  two log-budget tests ──► record(NUL-only line) × N
                              │
                              ├─► log ring        (what the tests check)
                              └─► process.stderr  (mirror, not checked)
                                        │
                                        ▼
                         ~66,000 NUL bytes per run in the CI log

record() writes a copy of each line to process.stderr. Two tests fill the log buffer with NUL-only lines to test the byte budgets. Each run printed about 66,000 NUL bytes, and local runs print them too. In a failed CI run, these bytes buried the real error.

Fix

Stub process.stderr.write only around the two NUL loops, and restore it in finally.

  • The two tests check the log ring and the /logs body. They never check stderr, so what they test does not change.
  • The stub returns true, so the backpressure latch in record() does not change.
  • The backpressure test still uses its own spy, and it passes.

Testing

  • vp test run platform/packages/api/test/unit/build-manager.test.ts: 315 passed.
  • NUL bytes in the output: 66,024 before the fix, 0 after it.

🤖 Generated with Claude Code

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) <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-08T09:13:43.268212Z 995d7e5 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://fix-platform-unit-nul-output-void-cloud.voidzero-docs.workers.dev (commit 995d7e5)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://20643465-void-cloud.voidzero-docs.workers.dev 995d7e5 2026-10-08T09:12:30.016Z Visit the dashboard ↗

@Brooooooklyn
Brooooooklyn merged commit c2db25b into main Oct 8, 2026
25 of 26 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/platform-unit-nul-output branch October 8, 2026 09:33
Brooooooklyn added a commit that referenced this pull request Oct 8, 2026
## Problem

`test (platform-unit)` sometimes dies on Linux with exit code 132, and
no test fails. Node 24's V8 aborts while it frees PGlite's WebAssembly
code in a worker thread:

```
# Fatal error in , line 0
# Check failed: jit_page_->allocations_.erase(addr) == 1.
  v8::internal::ThreadIsolation::UnregisterWasmAllocation
Process completed with exit code 132.
```

```
platform-unit (pool: threads, one process)
  ├─ worker: build-manager.test.ts      ✓
  ├─ worker: github-authority-migration (PGlite) finishes
  │            └─ V8 frees its Wasm code ──► fatal check ──► SIGILL
  └─ whole Vitest process dies ──► no summary, no failing test name
```

`platform-unit` runs every file as a worker thread in one Vitest
process. When one thread hits this V8 check, the whole process dies.
Five platform unit files start PGlite.

`bffa88e28` fixed the same abort for the API integration project: it
runs those files in forks on Linux. That fix did not cover the PGlite
files in `platform-unit`.

Seen on Oct 8:

- run 37742762058: 0.9 s after `github-authority-migration.test.ts`
finished, with three PGlite files not yet reported.
- run 37754922940 (#392): exit 132 two seconds into the run.

## Fix

Move the five PGlite files into a new project, `platform-unit-pglite`.
It uses forks on Linux and threads on other platforms. The other 138
platform unit files stay on threads.

```
before:  platform-unit (threads)  ── 143 files, PGlite included
after:   platform-unit (threads)  ── 138 files
         platform-unit-pglite     ──   5 PGlite files, forks on Linux
```

- CI already runs `--project 'platform-unit*'`, so it selects both
projects.
- `vp run test --unit` (`test/affected.mjs`) and `test:platform`
(`platform-*`) include the new project.
- A config test fails if a new platform unit file that imports PGlite is
not in `platform-unit-pglite`.
- The test bodies do not change.

The crash does not reproduce on demand. In Linux Docker with Node
24.21.0, a standalone script ran more than 3,000 PGlite worker teardowns
and did not abort. The fix follows where the CI crashes happened and the
earlier fix in `bffa88e28`.

## Testing

- `vp test run packages/void/test/unit/test-projects.test.ts`: 5 passed.
- `vp test run --project 'platform-unit*'`: 143 files, 2701 tests
passed.
- With the platform faked: Linux puts `platform-unit-pglite` on forks.
macOS and Windows keep threads.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant