Repository navigation
fix(child_process): expose parent-end pipe fd through stream._handle (port oven-sh/bun#39760) - #28
Merged
Merged
Conversation
Ports oven-sh#39760 at 3e1d66d, originally implemented by robobun. TypeScript's synchronous native API borrows child stdout/stdin _handle.fd, sets blocking mode, and unrefs the streams before synchronous pipe I/O. Expose live native descriptors without transferring their ownership, guard closed and buffer-only sources, and make stdin ref/unref edge-triggered. Retain the fork's testing_apis visibility and existing stdio tests while adding all four upstream cases. The native lifetime and blocking semantics are unchanged from the upstream proposal.
Declare the optional handle and File-source descriptor getter in the newer native-readable interfaces. These declarations emit identical JavaScript and preserve the tested runtime behavior.
steipete
force-pushed
the
codex/child-stdio-handle-fd
branch
from
September 30, 2026 05:40
b430504 to
8bda719
Compare
This was referenced Sep 30, 2026
This was referenced Oct 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TypeScript's synchronous native API borrows
child.stdout._handle.fdandchild.stdin._handle.fd, switches them to blocking mode, pauses/unrefs the streams, and usesfs.readSync/fs.writeSync. Bun's stdio wrappers lacked_handle, and stdin lacked stream-levelref()/unref(), preventing this transport from initializing.Ports oven-sh#39760 at
3e1d66db472a794a03228c60a6ba454117701950, originally implemented by @robobun. The port exposes live parent-end descriptors without transferring ownership, adds blocking-mode control, rejects closed or buffer-only descriptors, and makes stdin ref/unref edge-triggered so eager spawn initialization does not swallow the first unref. The fork's newer native-readable interfaces declare these optional properties.Rebase onto upstream sync #26
Rebased onto
7862bb3750dc05cdcaa55711a125c461930fbd63, the fork sync through upstreamba3f27d1d1ce359d4eed842c135f0f6fba1acb00. Qualified head:8bda719daf3546289914b9737dee3b11fc8fd5ae.subprocess.rsandFileSink.rsmerged cleanly. The sync'stesting_apis::close_stdin_writer,FileSink::on_closelifetime guard, TTY state/poll flags, and force-sync classification remain intact. The port'sset_stdio_blockinghelper and closed-descriptor gates retain their upstream semantics. The sync's lower-level async pipe-write changes also remain intact; they do not replace the raw descriptor blocking-mode control used by the synchronous transport.The only textual conflict was the changelog: all main entries were preserved and the stdio entry was placed below the existing child-signal entry. The old changelog-relocation commit became redundant and was dropped. No part of oven-sh#39760 was already supplied by the sync; no runtime change was dropped. All additions/deletions in the eight source/test files match the previously qualified port. Upstream oven-sh#36316 remains independent and is not included.
Rebased Bun proof
One new macOS arm64 release build, reporting
1.4.3-canary.1+8bda719da, completed successfully (210 seconds including monitoring). The SDK27 signpost patch is build-only, uncommitted, and excluded from this PR. The binary is ad-hoc signed and loads the consumer's native addons.child-process-stdio.test.jstest/js/node/child_process/test/js/node/net/rust:check-allThe suites used
bun run build:release -- --expose-internals test <path>. The net skips include its 25 debug-only fault-injection cases plus 12 existing platform/build gates. No test exclusions or assertions were changed, and no test retries were needed.Negative controls retained from the original qualification: all four added upstream cases fail on the supplied unpatched fork
ee83b78b1; Node 24.21.0 passes both W9 probes, while that unpatched fork fails atstdout._handle.fd. Those controls were not rerun or represented as builds of the new base. The two patched W9 probes were rerun on this rebased binary.Fresh OpenClaw consumer
Detached current
origin/mainat8dc03c36077131c99e88d90c3fa68eab37a50d55, freshpnpm install, TypeScript7.1.0-dev.20260920.1, Vitest5.0.1. Each file ran separately vianode scripts/run-vitest.mjs <file> --maxWorkers=1, withOPENCLAW_VITEST_RUNTIME=bun, the rebuilt Bun first on PATH, andTMPDIR=/private/tmp/w10tmpmode 0700. Node handled orchestration; the rebuilt Bun executed Vitest and workers.17/17 files and 108/108 tests pass, without retries or residual failures. Total wrapper time was 133.563 seconds. Times include setup/worker preparation.
src/agents/agent-bundle-mcp-requester-connect.import-boundary.test.tssrc/agents/agent-model-discovery.imports.test.tssrc/agents/code-mode.auto-results.test.tssrc/agents/harness/native-hook-relay.imports.test.tssrc/cli/program/register.database.import-boundary.test.tssrc/library.test.tssrc/plugin-sdk/provider-tools.test.tstest/scripts/audit-control-ui-dead-css.test.tstest/scripts/canvas-cli-import-closure.test.tstest/scripts/check-session-accessor-boundary.test.tstest/scripts/check-session-transcript-reader-boundary.test.tstest/scripts/check-sqlite-transaction-boundary.test.tstest/scripts/native-typescript.test.tstest/scripts/nodes-cli-import-closure.test.tstest/scripts/ts-topology.test.tstest/scripts/typecheck-inert.test.tstest/test-helper-extension-import-boundary.test.tsRuntime execution proof is macOS arm64. Cross-target checking is not Linux/Windows runtime execution. Tested binary SHA-256:
eba9b53ba922531101e079e45dd6515ca85732751fd879e1cdbba80a1fc150f6.Leave this PR open for coordinator review. No merge or release is part of this work order. No workflow or WebKit-pin edits are included.