Skip to content

feat(child_process,util): ChildProcess/Stream exports (#1856) + promisify(exec/execFile) (#1857) - #1861

Merged
proggeramlug merged 1 commit into
mainfrom
fix-1856-1857-cp-exports-promisify
May 26, 2026
Merged

proggeramlug merged 1 commit into
mainfrom
fix-1856-1857-cp-exports-promisify

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Summary

Closes the two follow-ups left from the streaming-spawn work (#1780 / #1858), which together make the test_parity_child_process gap test byte-identical to node --experimental-strip-types.

#1856 — child_process.ChildProcess / Stream named exports

A value-form read of child_process.ChildProcess (e.g. console.log(child_process.ChildProcess)) tripped the #463 unimplemented-surface gate at compile time, which blocked the whole gap test from compiling. Now:

  • ChildProcess is registered in the API manifest (as a class) and added to the runtime callable-export list, so it reads as [Function: ChildProcess].
  • Stream is registered as a manifest property and resolves to undefined (Node does not export it).
  • The console function formatter now falls back to the closure's own name property when no name is registered for the (shared bound-method) function pointer — so bound native exports print their real name. This also nudges events.EventEmitter / tty.ReadStream toward Node's output; no parity fixture asserted the old [Function (anonymous)].

#1857 — util.promisify(exec) / promisify(execFile)

main's general util.promisify (shipped separately) resolves to the single first-result value — but Node attaches a custom promisify hook to exec/execFile that resolves to { stdout, stderr }. Added a detection at the top of util_promisify::js_util_promisify: when the argument is the bound child_process.exec/execFile export, it returns a child_process-specific wrapper that runs the command (Perry's synchronous model) and yields an already-resolved Promise of { stdout, stderr }. exec/execFile also join the callable-export list so child_process.exec reads as a function (typeof === "function").

Test

  • test_parity_child_process (the canonical gap test) is now byte-identical to Node — removed from test-parity/known_failures.json.
  • New focused regression test test-files/test_issue_1856_1857_exports_promisify.ts (exports + promisify(exec/execFile)) is byte-identical.
  • Existing spawn-stream test still passes; cargo fmt --all --check clean; API docs regenerated.

Built on top of the merged #1858; integrates with main's general util.promisify rather than duplicating it.

…sify(exec/execFile) (#1857)

Closes the two follow-ups from the streaming-spawn work (#1780/#1858); together
they make the test_parity_child_process gap test byte-identical to
`node --experimental-strip-types`.

#1856 — `child_process.ChildProcess` now reads as `[Function: ChildProcess]`
and `child_process.Stream` as `undefined` (Node does not export it), instead of
the value-read tripping the #463 unimplemented-surface gate at compile time
(which previously blocked the whole gap test from compiling). Both are
registered in the API manifest (docs regenerated); ChildProcess joins the
runtime callable-export list; and the console function formatter now falls back
to the closure's `name` property when no name is registered for the (shared
bound-method) function pointer — so bound native exports print their real name
(also nudges events.EventEmitter / tty.ReadStream toward Node parity). No parity
fixture asserted the old `[Function (anonymous)]`.

#1857 — `util.promisify(child_process.exec)` / `promisify(execFile)` now resolve
to `{ stdout, stderr }` (Node's custom-promisify shape). main's general
util.promisify resolves only the single first-result value, so this hooks a
child_process-specific case into `util_promisify::js_util_promisify`: when the
argument is the bound exec/execFile export it returns a wrapper that runs the
command (Perry's synchronous model) and yields an already-resolved Promise of
`{ stdout, stderr }`. exec/execFile also join the callable-export list so
`child_process.exec` reads as a function.

The full test_parity_child_process gap test is removed from known_failures.
New regression test: test-files/test_issue_1856_1857_exports_promisify.ts.
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