Expose the "enhanced" stack trace from uncaught exceptions to the `uncaughtException` and `uncaughtExceptionMonitor` handlers on `process`
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- JavaScript
- Star
- 122k
- Fork
- 37.3k
- Merge trung bình
- 4 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 283
Mô tả
What is the problem this feature will solve?
In my app, I have a logging system which writes entries to files and/or the network in a machine-parsable form. I use the uncaughtException handler on process in order to get uncaught exceptions written out to this logging system. I noticed that if there's no uncaughtException handler, Node will print out an extra stack trace to the console indicating the call site of the <emitter>.emit('error', ...) call which emitted the ultimately-uncaught exception. However, it seems like there's no programmatic way for me to get that extra trace in my own handler.
This feature will solve the problem of being able to programmatically extract this extra — and quite useful! — information in a way that works well with a system that eschews the console.
What is the feature you are proposing to solve the problem?
I don't know what tactic would work best within the larger Node ecosystem, but as a straw-man suggestion:
Add a third argument to the uncaughtException and uncaughtExceptionMonitor callbacks when an "enhanced" error is available, containing information corresponding to the site and target of the emit() call. It could, for example, be a plain object containing an Error representing the call site and an object reference to the emitter itself. But if that's too dangerous, it might instead have strings representing that info. For example (in the former case), the following would nearly duplicate what the current default uncaughtException handler prints out to the console:
process.on('uncaughtException', (err, origin, emitInfo) => {
console.log('%s', err.stack);
if (emitInfo) {
const { emitter, emitSite } = emitInfo;
console.log(`Emitted 'error' event of ${emitter.constructor.name} instance at:\n%s`,
emitSite.stack);
}
});
What alternatives have you considered?
Having a separate process to scrape console output to find things that look like uncaught exceptions, so I can push them into the structured logging system. (Oof.)
Hướng dẫn đóng góp
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.
Hướng nghiên cứu
Issue không nêu tên tệp hoặc bài kiểm thử nào. Hãy bắt đầu bằng cách lần theo cách Node hiện đang xử lý process uncaughtException và uncaughtExceptionMonitor, cùng với đường dẫn trace nâng cao được mô tả trong báo cáo. Hoàn tất khi các handler có thể nhận thông tin bổ sung về emit-site và target bằng chương trình khi thông tin đó khả dụng, và hành vi này được bao phủ bằng các bài kiểm thử.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, nodejs
- Lĩnh vực
- backend
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 38/100