Error logging is called even when handled in custom handler.
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, nodejs
Hướng nghiên cứu
Issue không nêu tên file hoặc test nào. Hãy lần theo các entry point của custom error-handler và default error-handler, sau đó xác minh rằng các lỗi đã được xử lý không phát ra default error log, trong khi các lỗi được chuyển tiếp vẫn phát ra log đó, và access log vẫn giữ mã trạng thái cuối cùng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- JavaScript
- Star
- 1.5k
- Fork
- 127
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của jeremydaly/lambda-api
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
jeremydaly/lambda-api#356 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
jeremydaly/lambda-api#270 ·
-
Logger OutputCó thể làm lại được @naorpeled đã nhận 905 ngày trước và không có pull request nào đang mở. Đang mở
jeremydaly/lambda-api#259 · 1 bình luận · 1 người được giao ·
-
Is it possible to disable versioning?Có thể đã có người làm @naorpeled đã nhận 99 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
jeremydaly/lambda-api#257 · 5 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 38/100
jeremydaly/lambda-api#251 · 1 bình luận ·
Tất cả issue của jeremydaly/lambda-api
Issue tương tự
-
bug MVP
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
saayam-for-all/webapp#1911 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Focus] Accessibility (a11y) [Package] Grid [Type] Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Cancelled query leaves stale row index; next query on the connection returns leading empty slotsCó thể đã có người làm @pislm đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 7 ngày
-
Harden bayesian-waves-bg.js: add prefers-reduced-motion, pointer-events guard, and hidden-tab pauseĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
njitacm/njit-acm-website#109 ·