CLI crashes with an uncaught exception when the input file is missing
Los mantenedores suelen responder en 4 días
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
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de NaturalIntelligence/fast-xml-parser
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
NaturalIntelligence/fast-xml-parser#890 · 1 comentario ·
Los mantenedores suelen responder en 4 días
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
NaturalIntelligence/fast-xml-parser#888 · 2 comentarios ·
Los mantenedores suelen responder en 4 días
-
ignoreDeclaration does not ignore lower case doctype declarationQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NaturalIntelligence/fast-xml-parser#870 · 2 comentarios ·
Los mantenedores suelen responder en 4 días
-
Numeric character references (A, A) are not decoded unless htmlEntities is enabledPosiblemente ocupada @guocn la tomó hace 3 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 64/100
NaturalIntelligence/fast-xml-parser#892 · 2 comentarios ·
Los mantenedores suelen responder en 4 días
-
Enhance type definition for XMLParser `isArray` option when using TypeScriptQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
NaturalIntelligence/fast-xml-parser#803 · 21 comentarios · 2 reacciones ·
Los mantenedores suelen responder en 4 días
Todos los issues de NaturalIntelligence/fast-xml-parser
Issues similares
-
bug require-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
expressjs/expressjs.com#2549 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
vercel-labs/agent-skills#348 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
NanmiCoder/dsh-agent-teams#289 ·
Los mantenedores suelen responder en 1 día