Skip to content

Commit f43b61e

Browse files
committed
child_process: give names to promisified exec() and execFile()
1 parent d139b6d commit f43b61e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/child_process.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const {
4747
} = primordials;
4848

4949
const {
50+
assignFunctionName,
5051
convertToValidSignal,
5152
getSystemErrorName,
5253
kEmptyObject,
@@ -236,7 +237,7 @@ function exec(command, options, callback) {
236237
}
237238

238239
const customPromiseExecFunction = (orig) => {
239-
return (...args) => {
240+
return assignFunctionName(orig.name, function(...args) {
240241
const { promise, resolve, reject } = PromiseWithResolvers();
241242

242243
promise.child = orig(...args, (err, stdout, stderr) => {
@@ -250,7 +251,7 @@ const customPromiseExecFunction = (orig) => {
250251
});
251252

252253
return promise;
253-
};
254+
});
254255
};
255256

256257
ObjectDefineProperty(exec, promisify.custom, {

test/parallel/test-util-promisify-custom-names.mjs

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import fs from 'node:fs';
99
import readline from 'node:readline';
1010
import stream from 'node:stream';
1111
import timers from 'node:timers';
12+
import child_process from 'node:child_process';
1213

1314

1415
assert.strictEqual(
@@ -38,3 +39,12 @@ assert.strictEqual(
3839
promisify(timers.setTimeout).name,
3940
'setTimeout'
4041
);
42+
43+
assert.strictEqual(
44+
promisify(child_process.exec).name,
45+
'exec'
46+
);
47+
assert.strictEqual(
48+
promisify(child_process.execFile).name,
49+
'execFile'
50+
);

0 commit comments

Comments
 (0)