Error logging is called even when handled in custom handler.
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript, nodejs
Línea de trabajo
En el issue no se menciona ningún archivo ni prueba. Rastrea los puntos de entrada del controlador de errores personalizado y del controlador de errores predeterminado; después, verifica que los errores gestionados no emitan el registro de errores predeterminado, mientras que los errores reenviados sigan haciéndolo, y que el registro de acceso conserve el código de estado final.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
When the error logging is enabled, it is called even when the error is handled in a custom error handler middleware.
This is unintuitive for several reasons. Consider the following case.
//Validation middleware
api.use((req, _, next) => {
//Assume a function that validates the body and returns a boolean
if (!validate(req.body)) {
throw new CustomValidationError();
}
next();
});
/*Some routes registered here*/
//Error handling middleware
api.use((err, _, res, next) => {
//Handle validation errors and send the response
if (err.name === 'CustomValidationError') {
return res.status(422).json({reason: 'Some validation reason'});
}
next();
});
In this case, the first thing we see in the logs is something like INFO {"level":"fatal",..."statusCode":500}.
Clearly the error is not something that we would consider to be fatal, as we handle it and return a 4XX. Also, the status code says 500, because that's the default in the handling logic and we haven't overridden it at the point at which the log is written, but it's confusing to see these things for a request which is neither fatal nor a 500.
The access log will then be printed with the correct status code, which adds further confusion.
Finally, the readme states that we can "short-circuit" the default error handler by registering a custom one, which I would expect to mean that we only get the logging if we don't register a custom handler, or we call next(), because it seems intuitive that the logging is part of the default handler.
Thank you for taking time to read.
- Lenguaje dominante
- JavaScript
- Estrellas
- 1.5k
- Forks
- 127
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
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 jeremydaly/lambda-api
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
jeremydaly/lambda-api#356 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
jeremydaly/lambda-api#270 ·
-
Logger OutputQuizá libre de nuevo @naorpeled la tomó hace 904 días y no hay ningún pull request abierto. Abierto
jeremydaly/lambda-api#259 · 1 comentario · 1 asignado ·
-
Is it possible to disable versioning?Posiblemente ocupada @naorpeled la tomó hace 99 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
jeremydaly/lambda-api#257 · 5 comentarios ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 38/100
jeremydaly/lambda-api#251 · 1 comentario ·
Todos los issues de jeremydaly/lambda-api
Issues similares
-
Progress difficulty filter lists Hard before MediumPosiblemente ocupada @Pandamachi la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
sysprog21/codetrial#281 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[dsh-plugin.org | dsh-plugin-hub] plugin distribution incomplete: yjh051108/dsh-routing-suiteAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 71/100
yjh051108/dsh-routing-suite#227 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
needs-triage release-watch
Dificultad 1/5 Menos de una hora Aptitud para principiantes 76/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
remoteintech/remote-jobs#2271 ·
Los mantenedores suelen responder en 1 día