The API is undergoing major review and revision, but the techniques I will demonstrate today will still be relevant.
The API changes are "breaking" but not fundamentally different on a conceptual level.
There is no mention of foo(), bar(), etc.
All we have is that after the close event there was an Error.
called when an asynchronous operation is placed on the event queue
called just before an asynchronous operation is executed
called just after an asynchronous operation is executed
called when the C++ handle object is destroyed
"If you can't observe your software, you have no idea what it's doing." - C J Silverio
Use the AsyncWrap API to keep track of where our operations are within the call stack.
When an async operation is placed into the event queue - i.e. on init(), store the current call stack.
If things blow up, we can get some insight into what went wrong.
(Again note, context is lost)
lightbright - https://github.com/bucharest-gold/lightbright
async-hooks - https://github.com/AndreasMadsen/async-hook
clarify - https://github.com/AndreasMadsen/clarify
AsyncWrap Public API Proposal - https://github.com/nodejs/node-eps/pull/18
async_hooks initial implementation - https://github.com/nodejs/node/pull/8531