Skip to content

doc: fix return types for sync methods #58575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cflee
Copy link

@cflee cflee commented Jun 4, 2025

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 641653b 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
]

@nodejs-github-bot nodejs-github-bot added child_process Issues and PRs related to the child_process subsystem. needs-ci PRs that need a full CI run. labels Jun 4, 2025
@cflee cflee changed the title child_process: update return types for sync methods child_process: fix return types for sync methods Jun 4, 2025
@cflee cflee force-pushed the cflee/spawn-return-null branch from 9ea6082 to 66d7893 Compare June 4, 2025 17:09
@cflee
Copy link
Author

cflee commented Jun 5, 2025

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.

@lpinca
Copy link
Member

lpinca commented Jun 14, 2025

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

Copy link
Contributor

@Ethan-Arrowood Ethan-Arrowood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix PR title / commit subsystem from child_process to doc

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.
@cflee cflee force-pushed the cflee/spawn-return-null branch from 66d7893 to 9079219 Compare June 15, 2025 12:33
@cflee cflee changed the title child_process: fix return types for sync methods doc: fix return types for sync methods Jun 15, 2025
@cflee
Copy link
Author

cflee commented Jun 15, 2025

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

@lpinca lpinca added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 15, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 15, 2025
@nodejs-github-bot
Copy link
Collaborator

Copy link

codecov bot commented Jun 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.13%. Comparing base (641653b) to head (9079219).
Report is 80 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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
child_process Issues and PRs related to the child_process subsystem. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants