Closed
Description
I recently struggled with debugging a test suite that wouldn't exit. The (tape) tests all finished, but the final result wasn't printed out and the process just hung.
We eventually tracked the problem down to a few long-running setTimeout
s that, while fine in app code, needed to be cleared in the tests so that the process could exit.
This debugging process would have been a lot easier if there was a way to see what V8 had in the event loop, by call stack. Perhaps an API like:
setTimeout(() => {console.log('hi')}, 2000)
setTimeout(() => {console.log('hi')}, 1000)
process.getEventLoop( (stacks) =>
stacks.forEach(console.log.bind(console))
// ['setTimeout file.js:2']
// ['setTimeout file.js:1']
stacks
is an array of arrays sorted by their order in the event loop and containing the call stack for each item.
Does this already exist? Is it possible?