Repository navigation
fix: plugin capture fails on Bun/macOS for valid dependencies over 128 KiB - #159403
Conversation
|
🦞👀 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 September 29, 2026, 10:31 PM ET / September 30, 2026, 02:31 UTC (Revision 6). ClawSweeper reviewWhat this changesThe branch lets plugin generation capture fall back to a bounded descriptor copy when Bun on macOS returns EBADF, and tests that other runtime and error combinations still fail. Merge readiness✅ Ready for maintainer review Keep this PR open. Current main still propagates the reported Bun/macOS descriptor-copy error, while the branch has focused regression coverage and credible before-and-after production-boundary proof. The latest merge commit does not change the reviewed implementation. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw copies admitted plugin source files and dependencies into a private generation before loading them. The source-copy path reads an open file descriptor and supplies captured bytes for verification and plugin execution. flowchart LR
A[Plugin source and dependencies] --> B[Admit source file]
B --> C[Copy through descriptor path]
C --> D{Copy outcome}
D -->|Bun macOS EBADF| E[Bounded descriptor copy]
D -->|Success or other error| F[Captured bytes or error]
E --> F
F --> G[Verify and load plugin]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +11, Tests +86. Total +97 across 2 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Retain the narrow fallback in the plugin source-copy owner and its capture-boundary controls, then land through the normal exact-head gates. Do we have a high-confidence way to reproduce the issue? Yes. The linked report and PR body give a concrete Bun/macOS capture reproduction, and current main retains the rejecting path; this read-only review did not execute it. Is this the best way to solve the issue? Yes. The patch uses the existing bounded copy from the admitted descriptor and limits the new fallback to the demonstrated runtime and error. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8ddafc60fc43. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Bounded reproduction at The four CI failures were:
Each failing case passed twice locally on macOS, Node 26.10.0, at the exact head. Runs were sequential with
Walls include cold runtime-build/compiler-cache preparation, especially the first Gateway and npm runs. These local passes do not establish a fix for the CI failures. The added production fallback is gated on Darwin + Bun + EBADF; Linux/Node production execution does not enter that added branch. Per maintainer direction, rerunning only this run's failed jobs once. |
…8 KiB (openclaw#159403) * fix: fall back for Bun Darwin descriptor EBADF * test: cover Bun macOS plugin capture fallback * test: cover descriptor fallback through capture
On macOS, `fs.copyFile` and `fs.cp` fail with `EBADF` for regular-file `/dev/fd` sources above 128 KiB. Bun switches to `clonefile` and then Darwin’s pathname-based `copyfile` above that threshold. The latter compares pathname `stat.st_dev` with opened-descriptor `fstat.st_dev`; devfs descriptor paths have a synthetic device ID, so the identity check rejects a valid descriptor. After an unsuccessful clone, use the bounded copy loop for devfs path sources. Node path copies use positional reads from byte zero without advancing the original descriptor. The shared sequential reader remains available to `Bun.write`, including its non-seekable-input fallback. Ordinary clone fast paths and forced-clone failures are preserved. The source remains pinned through `/dev/fd`; the fix does not reopen its original filesystem pathname. Related: openclaw/openclaw#159313 and its application workaround openclaw/openclaw#159403. Qualified head: `11fbdbb8dd344463605ec6019b8b975cfa335794`, macOS release build, WebKit `f20ce7744553c910bcf16a33faf976af208de091`. - All 50 descriptor-path regression/control cases passed, covering threshold sizes, aliases, sync/callback/promise APIs, overwrite/truncation, exclusivity, forced cloning, contents, and offsets. - The added `Bun.write` fault-injection regression passed. It forces recoverable `fcopyfile` failure and verifies exact bytes from non-seekable stdin; this caught an overly broad positional-read change in the first draft, which is corrected by the separate readers. - `test/js/node/fs/fs.test.ts`: 660 passed, 16 skipped, 0 failed. - `test/js/node/fs/cp.test.ts`: 54 passed, 6 skipped, 0 failed. - Both full filesystem suites used `--max-concurrency 2`; assertions, timeouts, and internal stress loops were unchanged. An earlier run encountered a recursive-readdir timeout and subsequent FD-count failures. - Broader `test/js/bun/io/bun-write.test.js` on the corrected pre-integration head `4cec09fc2d`: 79 passed, 4 skipped, 1 timeout. The unchanged “writes as the body arrives, and a collected Response does not stop it” case also times out in the identical full suite on a separately built pre-change fork binary at `3fc6250eff3a284fa5b1aa7246e16e367795d3e4`. Both binaries can pass the case alone; this baseline-sensitive failure is not presented as a clean broader-suite result. - Codex review found no actionable P0–P2 findings. Formatting, `git diff --check`, and all applicable hosted checks passed. Stock Bun 1.4.2 reproduces the 131072/131073-byte boundary and the 172832-byte report. Node 26.10.0 passes all 15 standalone threshold/API/offset controls. Native probes confirm devfs for direct and symlink descriptor paths, `EINVAL` from `clonefile`, and the pathname/descriptor identity mismatch behind `copyfile`’s `EBADF`. The qualified head includes the landed patch-errno, injected-connection, and runtime-plugin-cache fixes. The only merge conflict was in the changelog, where both entries were retained. The integrated release build, both full filesystem suites, and the pipe-fallback regression passed again.
…8 KiB (openclaw#159403) * fix: fall back for Bun Darwin descriptor EBADF * test: cover Bun macOS plugin capture fallback * test: cover descriptor fallback through capture (cherry picked from commit b7303b1)
What Problem This Solves
Fixes plugin source capture failures with valid dependencies larger than 128 KiB on Bun for macOS.
Fixes #159313
Why This Change Was Made
On Darwin, Bun can return EBADF while copying a valid open source descriptor through /dev/fd. The fix sends only Darwin+Bun EBADF through the existing bounded
copyFileDescriptorSynchelper, preserving the admitted file identity and leaving other platforms and errors unchanged.User Impact
The reported plugin-load failure no longer stops at capture when Bun/macOS hits this descriptor-copy error.
Evidence
capturePluginGenerationArtifacton the same generated package and Darwin arm64/dev/fdpath. Before fix, Bun 1.4.2 on base 247258e returned EBADF for 172832 bytes; after fix, tested HEAD SHAd44153d33b504358820297279e3a51b253dfad7bcopied exact bytes.pnpm test src/plugins/plugin-generation-artifact.streaming.test.ts --maxWorkers=1passed (8 tests, 19.9s local wall, pinned pnpm 12.4.2). The generation-capture regression injects Bun/macOS EBADF and checks exact copied bytes and source currentness; Node/macOS EBADF, Bun/Linux EBADF, and Bun/macOS EIO remain errors.pnpm deadcode:fullpassed. The broadertest:changedselector expanded to theunit-fastproject and hit the 10-minute local runner limit; no assertion failure was reported before termination.Testing: proof-live.mjs
AI-assisted: built with Codex