node icon indicating copy to clipboard operation
node copied to clipboard

doc: fix return types for sync methods

Open cflee opened this issue 6 months ago β€’ 6 comments

For the sync methods spawnSync(), execSync() and execFileSync(), when the stdio option is set to anything other than 'pipe', the stdout and stderr returned from the C++ code will be null, and not a string or Buffer as currently documented.

The null originates from the C++ code where:

We can confirm the current behavior with:

const { execSync } = require('node:child_process');
const results = ["pipe", "ignore", "inherit"].map(option => {
  return execSync("pwd", { stdio: option });
});
console.log(results);

The output with a build of current main at 641653b2da1f7c698b8732e14ad45844d3932749 is:

/Users/cflee/projects/node
[
  <Buffer 2f 55 73 65 72 73 2f 63 66 6c 65 65 2f 70 72 6f 6a 65 63 74 73 2f 6e 6f 64 65 0a>,
  null,
  null
]

cflee avatar Jun 04 '25 17:06 cflee

There is also the overlapped option listed in the docs but when trying to use it on macOS, I get a similar assertion failed to #48476.

cflee avatar Jun 05 '25 02:06 cflee

It is a doc only change. We don't need to run CI. Can you please replace the subsystem in commit title to doc:?

lpinca avatar Jun 14 '25 14:06 lpinca

@lpinca @Ethan-Arrowood Thanks for the review, I've updated both the PR title and commit title subsystem to doc.

cflee avatar Jun 15 '25 12:06 cflee

CI: https://ci.nodejs.org/job/node-test-pull-request/67460/

nodejs-github-bot avatar Jun 15 '25 12:06 nodejs-github-bot

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 90.13%. Comparing base (641653b) to head (9079219). Report is 204 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #58575      +/-   ##
==========================================
- Coverage   90.21%   90.13%   -0.08%     
==========================================
  Files         635      637       +2     
  Lines      187494   188122     +628     
  Branches    36838    36893      +55     
==========================================
+ Hits       169144   169572     +428     
- Misses      11145    11308     +163     
- Partials     7205     7242      +37     
Files with missing lines Coverage Ξ”
lib/child_process.js 97.75% <100.00%> (ΓΈ)

... and 79 files with indirect coverage changes

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Jun 15 '25 13:06 codecov[bot]