From b364f8f9b687aa005f2fd32a0fd1025e69693080 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 4 Jul 2025 14:59:58 +0100 Subject: [PATCH 1/4] Handle deprecated calls to child_process with args --- .../@node-red/nodes/core/function/90-exec.js | 8 +++++++- .../node_modules/@node-red/registry/lib/installer.js | 5 +++-- .../lib/storage/localfilesystem/projects/git/index.js | 1 + packages/node_modules/@node-red/util/lib/exec.js | 10 +++++++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/packages/node_modules/@node-red/nodes/core/function/90-exec.js b/packages/node_modules/@node-red/nodes/core/function/90-exec.js index 23d94059e..02a908d4b 100644 --- a/packages/node_modules/@node-red/nodes/core/function/90-exec.js +++ b/packages/node_modules/@node-red/nodes/core/function/90-exec.js @@ -91,7 +91,13 @@ module.exports = function(RED) { const opts = isWindows ? { ...node.spawnOpt, shell: true } : node.spawnOpt /* istanbul ignore else */ node.debug(cmd+" ["+arg+"]"); - child = spawn(cmd,arg,opts); + if (opts.shell) { + // When called with shell: true, passing in separate args is deprecated in Node 24 + // so we need to join the command and args into a single string. + child = spawn([cmd].concat(arg).join(" "), opts); + } else { + child = spawn(cmd,arg,opts); + } node.status({fill:"blue",shape:"dot",text:"pid:"+child.pid}); var unknownCommand = (child.pid === undefined); if (node.timer !== 0) { diff --git a/packages/node_modules/@node-red/registry/lib/installer.js b/packages/node_modules/@node-red/registry/lib/installer.js index 3ffd65513..2d8cfe193 100644 --- a/packages/node_modules/@node-red/registry/lib/installer.js +++ b/packages/node_modules/@node-red/registry/lib/installer.js @@ -367,9 +367,10 @@ async function getModuleVersionFromNPM(module, version) { if (version) { installName += "@" + version; } + return new Promise((resolve, reject) => { - child_process.execFile(npmCommand,['info','--json',installName],{ shell: true },function(err,stdout,stderr) { + child_process.execFile(`${npmCommand} info --json ${installName}`, { shell: true },function(err,stdout,stderr) { try { if (!stdout) { log.warn(log._("server.install.install-failed-not-found",{name:module})); @@ -595,7 +596,7 @@ async function checkPrereq() { installerEnabled = false; } else { return new Promise(resolve => { - child_process.execFile(npmCommand,['-v'],{ shell: true },function(err,stdout) { + child_process.execFile(`${npmCommand} -v`,{ shell: true },function(err,stdout) { if (err) { log.info(log._("server.palette-editor.npm-not-found")); installerEnabled = false; diff --git a/packages/node_modules/@node-red/runtime/lib/storage/localfilesystem/projects/git/index.js b/packages/node_modules/@node-red/runtime/lib/storage/localfilesystem/projects/git/index.js index 983b4ca52..c7eec746b 100644 --- a/packages/node_modules/@node-red/runtime/lib/storage/localfilesystem/projects/git/index.js +++ b/packages/node_modules/@node-red/runtime/lib/storage/localfilesystem/projects/git/index.js @@ -417,6 +417,7 @@ module.exports = { log.trace("git init: "+JSON.stringify(result)); resolve(result); }).catch(function(err) { + console.log(err) log.trace("git init: git not found"); resolve(null); }); diff --git a/packages/node_modules/@node-red/util/lib/exec.js b/packages/node_modules/@node-red/util/lib/exec.js index 15b81aa89..6345438a6 100644 --- a/packages/node_modules/@node-red/util/lib/exec.js +++ b/packages/node_modules/@node-red/util/lib/exec.js @@ -57,7 +57,15 @@ module.exports = { return new Promise((resolve, reject) => { let stdout = ""; let stderr = ""; - const child = child_process.spawn(command,args,options); + let child + if (args && options.shell) { + // If we are using a shell, we need to join the args into a single string + // as passing a separate array of args is deprecated in Node 24 + command = [command].concat(args).join(" "); + child = child_process.spawn(command, options) + } else { + child = child_process.spawn(command, args, options); + } child.stdout.on('data', (data) => { const str = ""+data; stdout += str; From 1d2fd8a6048ff147a6621d55879d3f58c814e5f6 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 4 Jul 2025 15:00:33 +0100 Subject: [PATCH 2/4] Remove final use of util.log --- packages/node_modules/node-red/red.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/node_modules/node-red/red.js b/packages/node_modules/node-red/red.js index af0c34fa7..fdd38ed47 100755 --- a/packages/node_modules/node-red/red.js +++ b/packages/node_modules/node-red/red.js @@ -529,18 +529,18 @@ httpsPromise.then(function(startupHttps) { }); process.on('uncaughtException',function(err) { - util.log('[red] Uncaught Exception:'); + console.log('[red] Uncaught Exception:'); if (err.stack) { try { RED.log.error(err.stack); } catch(err2) { - util.log(err.stack); + console.log(err.stack); } } else { try { RED.log.error(err); } catch(err2) { - util.log(err); + console.log(err); } } process.exit(1); From 8430d6eb513615af012aa81c304b6a55e2ed7410 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 4 Jul 2025 15:01:30 +0100 Subject: [PATCH 3/4] add 24 to test matrix --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 70d36deb1..ee9c922ae 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [18, 20, 22] + node-version: [18, 20, 22, 24] steps: - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} From cf2af7988d7a45ec4d56a734ffc49fd8aa621f6f Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 4 Jul 2025 15:21:59 +0100 Subject: [PATCH 4/4] Update packages/node_modules/@node-red/runtime/lib/storage/localfilesystem/projects/git/index.js --- .../runtime/lib/storage/localfilesystem/projects/git/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/node_modules/@node-red/runtime/lib/storage/localfilesystem/projects/git/index.js b/packages/node_modules/@node-red/runtime/lib/storage/localfilesystem/projects/git/index.js index c7eec746b..983b4ca52 100644 --- a/packages/node_modules/@node-red/runtime/lib/storage/localfilesystem/projects/git/index.js +++ b/packages/node_modules/@node-red/runtime/lib/storage/localfilesystem/projects/git/index.js @@ -417,7 +417,6 @@ module.exports = { log.trace("git init: "+JSON.stringify(result)); resolve(result); }).catch(function(err) { - console.log(err) log.trace("git init: git not found"); resolve(null); });