Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

CLI crashes with an uncaught exception when the input file is missing

Abierto
#894 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 4 días

@troclaux ya está trabajando en esto.

Desde el 22/10/2026.

  • #895 de @troclaux — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
javascript, node.js
Área
cli

Línea de trabajo

Start with src/cli/cli.js, especially the fs.readFile callback, writeToFile, and ReadToEnd.readToEnd stdin callback described in the issue. Trace how each callback reports filesystem errors and how the CLI sets its exit code. Reproduce the missing input and unwritable output commands from the issue; done means errors are reported without an uncaught exception and the process exits nonzero. An open linked pull request (#895) already addresses this issue.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

  • Are you running the latest version?
  • Have you included sample input, output, error, and expected output?
  • Have you checked if you are using correct configuration?
  • Did you try online tool?
  • Have you checked the docs for helpful APIs and examples?
Description

The built-in CLI (src/cli/cli.js, fxparser) crashes with an uncaught exception and a stack trace when the input file doesn't exist. It's supposed to print its Seems an invalid file or stream. message. The same happens when the -o output file can't be written.

The try/catch around fs.readFile can't catch the throw err inside the callback, because the callback runs after the try block has already returned. The fs.writeFile callback in writeToFile and the ReadToEnd.readToEnd stdin callback have the same problem.

Version: 5.11.2 (master at 80e88a8), Node.js v22.18.0

Input
node src/cli/cli.js /nonexistent/missing.xml
echo '<a>1</a>' > in.xml && node src/cli/cli.js in.xml -o /nonexistent/dir/out.json
Code
fs.readFile(fileName, function(err, data) {
  if (err) {
    throw err; // not caught by the surrounding try/catch
  }
  callback(data.toString());
});
Output
file:///.../src/cli/cli.js:80
          throw err;
          ^

[Error: ENOENT: no such file or directory, open '/nonexistent/missing.xml'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/nonexistent/missing.xml'
}
expected data
Seems an invalid file or stream.Error: ENOENT: no such file or directory, open '/nonexistent/missing.xml'

The process should also exit with a non-zero code.

Would you like to work on this issue?

  • Yes
  • No
Lenguaje dominante
JavaScript
Estrellas
3.1k
Forks
398
Merge medio
3 d 9 h
PR fusionados (30 d)
1

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de NaturalIntelligence/fast-xml-parser

Todos los issues de NaturalIntelligence/fast-xml-parser

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.