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

Aberta Para iniciantes
#60,059 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 2 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
82/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
javascript, node.js
Domínio
cli, testing

Direção de pesquisa

Comece em private/react-native-fantom/runner/utils.js, especialmente em runCommandSync por volta das linhas 257–258, e examine os testes do runner em private/react-native-fantom/runner/__tests__/. Execute o reprodutor fornecido para o caso de comando inexistente ou adicione esse caso ao teste relevante. O trabalho estará concluído quando um comando que não consegue iniciar retornar um erro ENOENT com stdout vazio, enquanto um comando que é executado continuar retornando sua saída.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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

Linguagem predominante
C++
Estrelas
127k
Forks
25.5k
Merge médio
3d 22h
PRs com merge (30d)
235

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de react/react-native

Todas as issues de react/react-native

Issues semelhantes

Mais issues de C++

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.