doc: fix return types for sync methods
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:
- the C++ internal representation of the stdio pipes defaults to a null pointer and only gets replaced with an SyncProcessStdioPipe instance for
'pipe'stdiooptions - when returning the output array from C++ to JavaScript, C++ null pointer will be represented as JavaScript null
- therefore for non-
'pipe'stdiocases, it will be a null, and not a string or Buffer
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
]
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.
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 @Ethan-Arrowood Thanks for the review, I've updated both the PR title and commit title subsystem to doc.
CI: https://ci.nodejs.org/job/node-test-pull-request/67460/
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%> (ΓΈ) |
: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.