You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a (seldomly used) build target with the executor @nx/web:file-server, using a buildTarget in its options. Now I noticed that the target fails, with an unhelpful error:
Error: Build target failed: boardroom-feature-timeline:build-storybook:ci
at run (<...>\node_modules\@nx\web\src\executors\file-server\file-server.impl.js:138:27)
at fileServerExecutor (<...>\node_modules\@nx\web\src\executors\file-server\file-server.impl.js:151:9)
at fileServerExecutor.next (<anonymous>)
at startDevServer (<...>\node_modules\@nx\cypress\src\utils\start-dev-server.js:38:22)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async cypressExecutor (<...>\node_modules\@nx\cypress\src\executors\cypress\cypress.impl.js:15:22)
at async promiseToIterator (<...>\node_modules\nx\src\command-line\run\run.js:32:11)
at async getLastValueFromAsyncIterableIterator (<...>\node_modules\nx\src\utils\async-iterator.js:13:19)
at async iteratorToProcessStatusCode (<...>\node_modules\nx\src\command-line\run\run.js:43:29)
at async handleErrors (<...>\node_modules\nx\src\utils\params.js:9:16)
at async process.<anonymous> (<...>\node_modules\nx\bin\run-executor.js:59:28)
After removing the catch-clause, I got a better error message:
Error: spawnSync npx.cmd EINVAL
at Object.spawnSync (node:internal/child_process:1124:20)
at spawnSync (node:child_process:876:24)
at execFileSync (node:child_process:919:15)
at run (<...>\node_modules\@nx\web\src\executors\file-server\file-server.impl.js:133:54)
at fileServerExecutor (<...>\node_modules\@nx\web\src\executors\file-server\file-server.impl.js:148:9)
at fileServerExecutor.next (<anonymous>)
at startDevServer (<...>\node_modules\@nx\cypress\src\utils\start-dev-server.js:38:22)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async cypressExecutor (<...>\node_modules\@nx\cypress\src\executors\cypress\cypress.impl.js:15:22)
at async promiseToIterator (<...>\node_modules\nx\src\command-line\run\run.js:32:11)
at async getLastValueFromAsyncIterableIterator (<...>\node_modules\nx\src\utils\async-iterator.js:13:19)
at async iteratorToProcessStatusCode (<...>\node_modules\nx\src\command-line\run\run.js:43:29)
at async handleErrors (<...>\node_modules\nx\src\utils\params.js:9:16)
at async process.<anonymous> (<...>\node_modules\nx\bin\run-executor.js:59:28)
As stated there, on Windows you need to pass shell: true when spawning a child process via Node for Node release after April 9, 2024, otherwise it will fail with EINVAL.
Expected Behavior
Using the @nx/web:file-server with a buildTarget on Windows should work.
GitHub Repo
No response
Steps to Reproduce
Create a build-target using the @nx/web:file-server executor
Add a buildTarget
Run the build-target on a Windows machine with a current Node release
Error: spawnSync npx.cmd EINVAL
at Object.spawnSync (node:internal/child_process:1124:20)
at spawnSync (node:child_process:876:24)
at execFileSync (node:child_process:919:15)
at run (<...>\node_modules\@nx\web\src\executors\file-server\file-server.impl.js:133:54)
at fileServerExecutor (<...>\node_modules\@nx\web\src\executors\file-server\file-server.impl.js:148:9)
at fileServerExecutor.next (<anonymous>)
at startDevServer (<...>\node_modules\@nx\cypress\src\utils\start-dev-server.js:38:22)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async cypressExecutor (<...>\node_modules\@nx\cypress\src\executors\cypress\cypress.impl.js:15:22)
at async promiseToIterator (<...>\node_modules\nx\src\command-line\run\run.js:32:11)
at async getLastValueFromAsyncIterableIterator (<...>\node_modules\nx\src\utils\async-iterator.js:13:19)
at async iteratorToProcessStatusCode (<...>\node_modules\nx\src\command-line\run\run.js:43:29)
at async handleErrors (<...>\node_modules\nx\src\utils\params.js:9:16)
at async process.<anonymous> (<...>\node_modules\nx\bin\run-executor.js:59:28)
Package Manager Version
No response
Operating System
macOS
Linux
Windows
Other (Please specify)
Additional Information
The incorrect code is in nx/packages/web/src/executors/file-server/file-server.impl.ts, lines 160-162:
execFileSync(pmCmd,args,{stdio: [0,1,2],});
On Windows, pmCmd is npx.cmd. This will fail, due to the fixed CVE. A possible fix:
As a sidenote, catching an error, but then just logging a generic "build target failed" (lines 163-166) is not very helpful when trying to find out why there was a failure.
The text was updated successfully, but these errors were encountered:
DanielRose
changed the title
Executor @nx/web:file-server with buildTarget fails on Windows@nx/web:file-server with buildTarget fails on Windows
May 28, 2024
Current Behavior
I have a (seldomly used) build target with the executor
@nx/web:file-server
, using abuildTarget
in its options. Now I noticed that the target fails, with an unhelpful error:After removing the catch-clause, I got a better error message:
That led me to the following CVE from Node:
https://nodejs.org/en/blog/vulnerability/april-2024-security-releases-2#command-injection-via-args-parameter-of-child_processspawn-without-shell-option-enabled-on-windows-cve-2024-27980---high
As stated there, on Windows you need to pass
shell: true
when spawning a child process via Node for Node release after April 9, 2024, otherwise it will fail with EINVAL.Expected Behavior
Using the
@nx/web:file-server
with abuildTarget
on Windows should work.GitHub Repo
No response
Steps to Reproduce
@nx/web:file-server
executorbuildTarget
Nx Report
Failure Logs
Package Manager Version
No response
Operating System
Additional Information
The incorrect code is in
nx/packages/web/src/executors/file-server/file-server.impl.ts
, lines 160-162:On Windows,
pmCmd
isnpx.cmd
. This will fail, due to the fixed CVE. A possible fix:As a sidenote, catching an error, but then just logging a generic "build target failed" (lines 163-166) is not very helpful when trying to find out why there was a failure.
The text was updated successfully, but these errors were encountered: