diff --git a/lib/child_process.js b/lib/child_process.js index 5c853716a26..21616c69f87 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -47,6 +47,7 @@ const { } = primordials; const { + assignFunctionName, convertToValidSignal, getSystemErrorName, kEmptyObject, @@ -236,7 +237,7 @@ function exec(command, options, callback) { } const customPromiseExecFunction = (orig) => { - return (...args) => { + return assignFunctionName(orig.name, function(...args) { const { promise, resolve, reject } = PromiseWithResolvers(); promise.child = orig(...args, (err, stdout, stderr) => { @@ -250,7 +251,7 @@ const customPromiseExecFunction = (orig) => { }); return promise; - }; + }); }; ObjectDefineProperty(exec, promisify.custom, { diff --git a/test/parallel/test-util-promisify-custom-names.mjs b/test/parallel/test-util-promisify-custom-names.mjs index 3ff05d907b5..79da972ae20 100644 --- a/test/parallel/test-util-promisify-custom-names.mjs +++ b/test/parallel/test-util-promisify-custom-names.mjs @@ -9,6 +9,7 @@ import fs from 'node:fs'; import readline from 'node:readline'; import stream from 'node:stream'; import timers from 'node:timers'; +import child_process from 'node:child_process'; assert.strictEqual( @@ -38,3 +39,12 @@ assert.strictEqual( promisify(timers.setTimeout).name, 'setTimeout' ); + +assert.strictEqual( + promisify(child_process.exec).name, + 'exec' +); +assert.strictEqual( + promisify(child_process.execFile).name, + 'execFile' +);