Skip to content

feature request: a way to inspect what's in the event loop #1128

Closed
@joeybaker

Description

@joeybaker

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 setTimeouts 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions