Fantom's runCommandSync throws a TypeError for a command that cannot start, instead of returning its ENOENT error

未關閉 適合新手
#60,059 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 2 天內回覆

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
82/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
javascript, node.js
領域
cli, testing

研究方向

從private/react-native-fantom/runner/utils.js開始,特別檢查第257–258行附近的runCommandSync,並查看private/react-native-fantom/runner/__tests__/底下的runner測試。執行提供的缺少命令重現程式,或將該案例加入相關測試中。當無法啟動的命令回傳帶有空stdout的ENOENT錯誤,而能執行的命令仍回傳其輸出時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

Needs: Author Feedback Needs: Repro
Description

runCommandSync in private/react-native-fantom/runner/utils.js returns stdout: result.stdout.toString() (L257), while stderr on the next line reads result.stderr?.toString() ?? '' (L258). When spawnSync cannot start the command, result.stdout is undefined, so runCommandSync throws TypeError: Cannot read properties of undefined (reading 'toString') and never returns the result whose error is spawnSync <command> ENOENT.

runBuck2Sync goes through it (L328), so where buck2 is missing, the tester and Hermes compiler builds throw this TypeError before reaching their throw new Error(getDebugInfoFromCommandResult(result)) (tester.js L85, hermesc.js L73). The same goes for a missing hermesc binary (hermesc.js L119).

Steps to reproduce
  1. In a checkout of main (9a4ef4d7984) after yarn install, put runCommandSyncMissingCommand-test.js from the reproducer below in private/react-native-fantom/runner/__tests__/ and run yarn jest private/react-native-fantom/runner/__tests__/runCommandSyncMissingCommand-test.js; or run node repro.cjs <path to the checkout> from the reproducer, which copies that test in, runs it, removes it, and exits 1 while the defect shows.
runCommandSync('fantom-command-that-does-not-exist', [], {});

Expected: it returns a result whose error.code is ENOENT and whose stdout is '', so getDebugInfoFromCommandResult reports the spawn error; a command that runs still returns its output.
Actual: it throws TypeError: Cannot read properties of undefined (reading 'toString') at utils.js:257.

React Native Version

main at 9a4ef4d7984 (nightly)

Affected Platforms

Build - Windows

Output of npx @react-native-community/cli info
Not applicable: this is Fantom's runner in React Native's own repository. The reproducer's run:
react-native 9a4ef4d7984 (2026-11-16), Windows_NT 10.0.26300, node v26.12.1
Stacktrace or Logs
react-native 9a4ef4d7984 (2026-11-16), Windows_NT 10.0.26300, node v26.12.1
private/react-native-fantom/runner/utils.js:257: stdout: result.stdout.toString(),
private/react-native-fantom/runner/utils.js:258: stderr: result.stderr?.toString() ?? '',
copied runCommandSyncMissingCommand-test.js to private/react-native-fantom/runner/__tests__/
$ yarn jest private/react-native-fantom/runner/__tests__/runCommandSyncMissingCommand-test.js
removed private/react-native-fantom/runner/__tests__/runCommandSyncMissingCommand-test.js
jest exited 1
  failed: reports a command that cannot start through its result
  passed: returns the output of a command that runs
runCommandSync('fantom-command-that-does-not-exist', [], {}): threw TypeError: Cannot read properties of undefined (reading 'toString')
  at toString (private\react-native-fantom\runner\utils.js:257:27)
runCommandSync(node, ['-e', 'process.stdout.write("ok")'], {}): returned status 0, error null, stdout "ok"
SUMMARY: runCommandSync('fantom-command-that-does-not-exist', [], {}) throws "TypeError: Cannot read properties of undefined (reading 'toString')" instead of returning the ENOENT spawn error; expected a result with error.code ENOENT and stdout ''
MANDATORY Reproducer

https://github.com/YevheniiKotyrlo/rn-fantom-run-command-sync-repro — node repro.cjs <path to a react-native checkout> exits 1 while runCommandSync throws for a command that cannot start, and 0 once it returns the ENOENT error with stdout ''.

Screenshots and Videos

No response

主要語言
C++
星號
127k
分支
25.5k
平均合併
3 天 22 小時
30 天內合併 PR
235

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

react/react-native 的其他 Issue

查看 react/react-native 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。