Error logging is called even when handled in custom handler.
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, nodejs
Direzione di ricerca
Nell’issue non sono indicati file o test. Traccia i punti di ingresso dell’handler degli errori personalizzato e dell’handler degli errori predefinito, quindi verifica che gli errori gestiti non producano il log degli errori predefinito, mentre gli errori inoltrati continuino a produrlo, e che il log di accesso mantenga il codice di stato finale.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- JavaScript
- Stelle
- 1.5k
- Fork
- 127
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di jeremydaly/lambda-api
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
jeremydaly/lambda-api#356 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
jeremydaly/lambda-api#270 ·
-
Logger OutputForse di nuovo libera @naorpeled l’ha presa 904 giorni fa e non c’è nessuna pull request aperta. Aperta
jeremydaly/lambda-api#259 · 1 commento · 1 assegnatario ·
-
Is it possible to disable versioning?Forse già presa @naorpeled l’ha presa 99 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
jeremydaly/lambda-api#257 · 5 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 38/100
jeremydaly/lambda-api#251 · 1 commento ·
Tutte le issue di jeremydaly/lambda-api
Issue simili
-
[dsh-plugin.org | dsh-plugin-hub] plugin distribution incomplete: yjh051108/dsh-routing-suiteAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 71/100
yjh051108/dsh-routing-suite#227 ·
-
needs-triage release-watch
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 76/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
dusk-network/exu#17 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
jspreadsheet/ce#1809 ·
-
documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 91/100
githubnext/gh-aw-workshop#4458 ·
I maintainer di solito rispondono entro 1 giorno