Repository navigation
fix(test): frozen admission test fails with spawn ETXTBSY when a sibling test forks during the native parser copy - #162969
Conversation
…ing test forks during the native parser copy package-acceptance-workflow's provisionParser() copied the native TypeScript platform package with an unfiltered recursive cpSync. On Node 24 that path runs in C++ (cpSyncCopyDir -> std::filesystem::copy_file) and opens the destination without O_CLOEXEC. The tooling Vitest project runs in the threads pool, so a sibling file's thread can fork a child mid-copy; the child keeps a writable fd to the copied tsc across exec and the frozen bundle contract's later spawn of tsc fails with ETXTBSY. Sibling fixtures had patched the same class three different ways. Route every native TypeScript package copy through one copyNativeCompilerPackage helper in native-boundary-fixture.ts (filtered cpSync, i.e. libuv copyFileSync with O_CLOEXEC), drop the joined child-process writer, and add a Linux regression that forks paced long-lived children from a worker thread during the copy and then execs the copied compiler.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 4:08 PM ET / 20:08 UTC. ClawSweeper reviewWhat this changesThe branch centralizes safe native compiler copying across test fixtures and adds a Linux regression for executing the copied compiler while sibling child processes remain alive. Merge readiness✅ Ready for maintainer review This PR remains useful: current main and the latest release retain the affected unfiltered compiler copy. The focused fixture repair has credible reported red/green evidence, and no introduced blocking defect was found. Priority: P2 Review scores
Verification
How this fits togetherRelease-workflow tests copy an installed TypeScript compiler into isolated fixtures before checking source admission. These copies must remain executable when other test threads start child processes. flowchart TD
A[Installed compiler package] --> B[Shared fixture copy]
C[Sibling test threads] --> D[Child processes]
B --> E[Isolated compiler copy]
E --> F[Source admission tests]
D --> G[Concurrent execution check]
E --> G
Before mergeNone. Agent review detailsSecurityNone. PR surfaceTests +74. Total +74 across 5 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep compiler-copy safety in the shared fixture owner and retain the real-process regression for descriptor inheritance. Do we have a high-confidence way to reproduce the issue? Yes: the Linux regression exercises real sibling forks during a native compiler copy, and the PR reports 10/10 failures with the original implementation. This reviewer inspected the path without executing it. Is this the best way to solve the issue? Yes: centralizing the existing filtered-copy workaround fixes the missed fixture and removes the separate writer-process workaround without changing admission policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7b4623dc4cca. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
* origin/main: fix(gateway): report approved-but-narrowed scope upgrades truthfully (#162951) fix: allow session-scoped shared publication reads (#162984) refactor(sessions): share session creation orchestration (#161336) perf(gateway): show the first chat sooner after a Gateway start (#162936) refactor(scripts): share npm verification command execution (#162978) fix(browser): clear MCP runtime cache after profile tests (#162982) fix(test): checkout fixture tests fail healthy runs on loaded macOS hosts (#162888) ci: bound PR extension lint to direct owners and smoke packages fix(ci): await native declaration discovery teardown feat(qa): drive forwarded text+photo bursts in Telegram userbot scenarios (#162906) build(macos): pin the app runtime to OpenClaw Bun 17c9ecf9eb (#162570) fix(test): frozen admission test fails with spawn ETXTBSY when a sibling test forks during the native parser copy (#162969) fix(ci): give direct published-driver callers the CI cell envelope (#162837) test(gateway): remove low-value tests (batch d136) (#162921)
…ing test forks during the native parser copy (openclaw#162969) * fix(test): frozen admission test fails with spawn ETXTBSY when a sibling test forks during the native parser copy package-acceptance-workflow's provisionParser() copied the native TypeScript platform package with an unfiltered recursive cpSync. On Node 24 that path runs in C++ (cpSyncCopyDir -> std::filesystem::copy_file) and opens the destination without O_CLOEXEC. The tooling Vitest project runs in the threads pool, so a sibling file's thread can fork a child mid-copy; the child keeps a writable fd to the copied tsc across exec and the frozen bundle contract's later spawn of tsc fails with ETXTBSY. Sibling fixtures had patched the same class three different ways. Route every native TypeScript package copy through one copyNativeCompilerPackage helper in native-boundary-fixture.ts (filtered cpSync, i.e. libuv copyFileSync with O_CLOEXEC), drop the joined child-process writer, and add a Linux regression that forks paced long-lived children from a worker thread during the copy and then execs the copied compiler. * test: keep the regression's worker cleanup on the worker_threads postMessage shape
What Problem This Solves
Fixes: the
core-tooling-2shard intermittently failspackage-acceptance-workflow.test.ts› "frozen admission workflow barriers / runs the actual June workflow request and shared parser before producers" withfrozen bundle contract: unable to read selected bundle source: spawn ETXTBSYwhen another test file in the same Vitest process forks a child while the fixture copies the native TypeScript compiler.User Impact
No user-visible change. CI stops flaking on this test. Every fixture that copies a native TypeScript package for later execution now goes through one helper that cannot leave sibling-forked children holding the copied compiler open for writing.
Why This Change Was Made
provisionParser()copied the@typescript/typescript-<platform>-<arch>package with an unfiltered recursivefs.cpSync. On Node 24 (checked on 24.19 and 24.21) that path runs in C++ (copyDir→fsBinding.cpSyncCopyDir→std::filesystem::copy_file), and syscall tracing on Linux showedlib/tscopened asO_WRONLY|O_CREAT|O_TRUNCwithoutO_CLOEXEC. With a JSfilter, Node copies each file throughcopyFileSync, and libuv opens it asO_WRONLY|O_CREAT|O_CLOEXEC. The tooling project runs in thethreadspool, so a sibling file's thread can fork during the copy. That child keeps the writable fd across its own exec, and the frozen bundle contract's lazyspawn(tsc)(typescriptsyncChannel.js) then fails with ETXTBSY. Node'sChildProcess.spawnthrows that synchronous errno as the barespawn ETXTBSYseen in CI.Sibling fixtures had already fixed this same class three different ways: the
filter: () => truetrick innative-boundary-fixture.tsandlive-docker-stage.test.ts, and a joined child-process writer inpreflight-frozen-target-contracts.test.ts. This site was missed. This PR gives the job one owner,copyNativeCompilerPackageintest/scripts/native-boundary-fixture.ts, moves all four fixtures onto it, and deletes the joined-writer workaround (one fewer Node process per fixture).The new
test/scripts/native-boundary-fixture.test.tsis a Linux-only regression. A worker thread forks long-livedsh -c 'printf .; exec sleep 30'children, waiting for each child's first byte before forking the next. That byte proves the child has exec'd and dropped any close-on-exec descriptor. Meanwhile the helper copies the real platform package, and the test then execs the copiedtsc. The fork count self-throttles to exec latency, and the 256 cap is only a non-fatal resource bound, so a slow disk cannot turn it into a false red.Node's own
copyDircarries a TODO to move filtered copies into C++ as well. If that ever lands, this regression is what will catch the helper silently losing close-on-exec.Evidence
All runs on Blacksmith Testbox through
node scripts/crabbox-wrapper.mjs(Linux 6.6, Node 24.19.0):779880c635c2: rebuiltcore-tooling-2viacreateNodeTestShardBundles({ includeReleaseOnlyToolingShards: true })and ranscripts/ci-run-node-test-shard.mtswithOPENCLAW_NODE_TEST_GROUPS_JSON. All 3/3 replays passed (281 s, 231 s, 270 s), consistent with the reported timing dependence. The regression is the deterministic repro.cpSync(sha256-verified swap and restore), it failed with ETXTBSY in 10/10 runs. With the fix it passed 20/20. Paced child counts were 5–9 red and 7–13 green.package-acceptance-workflow.test.ts20/20 standalone,core-tooling-23/3 in original file order with no ETXTBSY, and all 22 fixture-caller files green (1,219 tests passed, 12 skipped). Planner/inventory guards passed (the new file is auto-owned bycore-unit-fast-2).node scripts/check-changed.mjs --base origin/mainpassed, including root-test oxlint for every touched file andtsgo:test:root; regression 15/15 more runs; oxfmt 0.68.0 andgit diff --checkclean. Touchingnative-boundary-fixture.tsbrings its pre-existingcurlylint violation onmaininto changed-file lint, so this PR braces thatif.pnpm test test/scripts/native-boundary-fixture.test.ts --maxWorkers=1takes ~1.5 s command wall and ~106 ms test time.Follow-ups, not in this PR:
test/scripts/pr-wrapper.test-support.tsandpr-wrappers.test.tscopy shebang wrappers that are later exec'd directly and may belong to the same class.declaration-fixture-packages.tsalready uses a filtered copy and was left as is, because its filter intentionally excludes nestednode_modules.