wtfnode is a utility designed to help Node.js developers diagnose why their applications are not exiting gracefully. It provides enhanced and human-readable insights into active event loop handles, such as timers, sockets, and servers, which prevent a Node.js process from terminating. Leveraging Node's internal `process._getActiveHandles()`, wtfnode breaks down complex handle information into actionable details, including call site origins for listeners, making it easier to pinpoint the exact code keeping a program alive. The current stable version, 0.10.1, functions as a crucial diagnostic tool for stalled applications, differentiating itself from raw Node.js introspection by offering a higher-level, more interpretable view of the event loop. Its release cadence is driven by the community's need for robust debugging solutions for persistent processes.
npm install wtfnodeVerified import paths — ran on the pinned version, not inferred.
Demonstrates module usage by setting up a `setInterval` and an HTTP server, then using `wtf.dump()` to report open handles when the process receives a SIGINT signal.
Manually inspect the provided source line and context to identify the original function or module creating the timer.
Investigate the parent process that spawned the current application to understand why the IPC channel remains open.
Press Ctrl+C twice to force-terminate processes stuck in infinite loops when using `wtfnode` globally. For module usage, ensure your SIGINT handler allows for `wtf.dump()` to complete and the process to exit.
This warning can typically be ignored. If persistent, try delaying the call to `wtf.dump()` slightly within the child process.
Add `wtfnode` to your application and call `wtf.dump()` when you suspect the process should exit (e.g., on `SIGINT` or at the end of a long-running task) to identify the specific open handles.
Examine the `module.js:Line` indicated in the output. This line points to where the timer was originally set. Ensure all long-running timers are explicitly cleared when no longer needed using `clearInterval()` or `clearTimeout()`.
Locate the code at `/path/to/connection.js:Line` to identify the socket's origin. Ensure all database connections, HTTP servers, or other network resources are explicitly closed or terminated when your application is done with them.
No dependency data recorded yet.