Add Promise-based versions for some functions in child_process
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 283
Description
What is the problem this feature will solve?
It would be nice if child_process functionality, such as exec and execFile, had Promised based versions by default. Currently it does not, see https://nodejs.org/api/child_process.html
Note that only child_process functions that can be async/await should be considered. This does not include things such as fork or spawn.
What is the feature you are proposing to solve the problem?
A new child_process/promises import path that can be used similar to how fs promises are used:
// Using ESM Module syntax:
import { exec } from 'child_process/promises';
try {
const { stdout } = await exec(
'sysctl -n net.ipv4.ip_local_port_range'
);
console.log('successfully executed the child process command');
} catch (error) {
console.error('there was an error:', error.message);
}
The ask is basically that child_process/promises could just return a variant such as const exec = util.promisify(process.exec); as a convenience.
What alternatives have you considered?
I am already using const exec = util.promisify(process.exec); but that is not as nice. And this new proposal follows along what is happening in other Node.js APIs.
(The original ask in https://github.com/nodejs/node/issues/38823 was perceived as asking for the entire module and all APIs to be async/await. This issue here narrows it down to only focus on the functions that can be.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the proposed child_process/promises entry point with the existing fs promises API and the scope discussed in issue #38823. Determine which async-capable child_process functions should be exposed, then verify the API shape, documentation, and tests cover those functions without including fork or spawn.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100