Investigation of post-mortem debugging with Promises. #45
Description
I am a graduate student at the IBM Centre for Advanced Studies—Atlantic at the University of New Brunswick working with @mhdawson. We are interested in working on post-mortem debugging for promises in Node.js as part of our research and are hoping to get the group’s input as we tackle this problem. I realize from reading the Issues that there isn’t consensus on a solution and although I am not yet a Node expert myself, I am willing to dedicate time to contribute towards a possible fix.
Our current plan would be to:
- Develop a set of test cases that show the problem of not being able to capture stack traces, core dumps etc. for unhandled exceptions that cause promise rejections.
- Implement and test a number of different options based on the suggestions in the pull requests so far, as well as new ideas we come up with.
- Document what can or cannot be captured in each option and the overhead of doing so.
- Receive input on different options, tradeoffs, and iterate as required.
- Submit a final pull request to add the most suitable solution from the investigation above.
Some of the ideas we would plan to test would include:
- Capturing different levels of information (stack trace, core dump etc.) to find a good balance between the overhead and information captured.
- Using the V8 API to determine the reason for a promise rejection.
- Adopting a double-run approach. The call stack and relevant metadata for an unhandled rejection are captured on the first pass. Then during the second pass, the rejections are tracked and compared with previous data to determine if a core dump is necessary. We want to analyze when to output or abort and whether it is preferential to do so immediately.
- Experimenting with when to capture information or abort and the impact this has on existing code using promises.
- Building up more information over time to help make better decisions on when to capture information.
We plan to keep this issue up to date with pointers to a fork that includes the code for the options we experiment with.
If you have any suggestions on what we should consider looking at or would like to collaborate on this effort just let me know.