Skip to content

Run PGlite unit tests in separate processes on Linux - #393

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

Brooooooklyn merged 1 commit into
mainfrom
fix/platform-unit-flake

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Member

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:

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

Node 24 on Linux can abort with a V8 fatal check in
ThreadIsolation::UnregisterWasmAllocation while it frees PGlite's Wasm
code after a file finishes in a worker thread. The abort kills the
shared Vitest process, so CI shows no summary and no failing test.

The API integration project already uses forks on Linux for this
reason. Move the five PGlite files out of platform-unit into a sibling
platform-unit-pglite project with the same Linux forks pool, and keep
the other platform unit files on threads. CI's --project
'platform-unit*' selects both projects, and a config test keeps any new
PGlite unit file in the new project.

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:33:58.886958Z a9ba8c0 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-flake-void-cloud.voidzero-docs.workers.dev (commit a9ba8c0)

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://5723778f-void-cloud.voidzero-docs.workers.dev a9ba8c0 2026-10-08T09:33:09.808Z Visit the dashboard ↗

@Brooooooklyn
Brooooooklyn merged commit cf45d55 into main Oct 8, 2026
20 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/platform-unit-flake branch October 8, 2026 09:45
Brooooooklyn added a commit that referenced this pull request Oct 8, 2026
## Problem

The CI `test (ubuntu-latest, unit)` job can die on Linux with exit code
132, and no test fails. This is the same Node 24 V8 abort that #393
fixed for `platform-unit`:

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

```
unit (pool: threads, one process)
  ├─ worker: platform-database-lock.test.ts (PGlite) finishes
  │            └─ V8 frees its Wasm code ──► fatal check ──► SIGILL
  └─ whole Vitest process dies ──► 107–130 of 382 files never report
```

The SDK `unit` project runs 4 PGlite files in worker threads:

- `packages/void/test/unit/db-export-roundtrip.test.ts`
- `packages/void/test/unit/platform-database-lock.test.ts`
- `packages/void/test/unit/platform-database-migrations.test.ts`
- `packages/void/test/unit/runner-pg.test.ts`

Seen twice on Oct 8, both with `vp test run --project unit --project
cli-unit` on Node 24.21.0:

| run / job | abort | last PGlite file done before it |
| --- | --- | --- |
| 37722871396 / 113134327555 | 03:30:30 | `platform-database-lock` (2.5
s before) |
| 37723925583 / 113137655099 | 03:43:48 | `runner-pg` (8.6 s before) |

No other Wasm runs in that job. `cli-unit` has no PGlite file. The SDK
integration PGlite test already runs in forks.

## Fix

Move the 4 files into a new project, `unit-pglite`. It uses forks on
Linux and threads on other platforms. All other options match `unit`:
the scheduling group, the worker limit, and the Windows timeout.

```
before:  unit (threads)         ── 382 files, PGlite included
after:   unit (threads)         ── 378 files
         unit-pglite            ──   4 PGlite files, forks on Linux
```

- These places now name `unit-pglite`: the CI unit shard, `test:unit`,
the affected runner's `--unit` list, and `TESTING.md`.
- The existing "every SDK unit file exactly once" test now includes
`unit-pglite`.
- The PGlite placement check that #393 added to `test-projects.test.ts`
is removed. It tested the test configuration, not product behavior.
- The test bodies do not change.

## Testing

- `vp test run --project unit --project unit-pglite --project cli-unit`
(the CI command): 394 files, 7585 tests passed.
- `vp test run --project unit-pglite --pool forks`: 4 files, 28 tests
passed.
- `vp test list`: the 4 files are only in `[unit-pglite]`, and no file
runs twice.
- With the platform faked: Linux selects forks for `unit-pglite`, and
macOS and Windows select 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