Prints out information about the process's active handles, including function source and location.
var activeHandles = require('active-handles');
// run your program, launch a server, call setTimeout or similar
// in order to create some handles and then call the below
activeHandles.print();Shows handles of multiple types created via examples/mixed.js
npm install active-handles
For any version <= v1.6.2 the setInterval function has to be hooked in order for this to work for setInterval
created handles.
In order to do that call activeHandles.hookSetInterval() before any calls to setInterval occurr. This is
demonstrated in this example.
Handles of net and http modules log handles from inside core instead of your handle, leaving you to hunt down
where you created these connections.
-
Gathers information about all currently active handles. Active handles are obtained via
process._getActiveHandlesand location and name of each is resolved.Name Type Argument Description optionsObject opts.handlesArray.<Object>= <optional>
handles to get info for (default:
process._getActiveHandles())opts.sourceBoolean <optional>
include source (default:
true), included either way ifhighlight=trueopts.highlightBoolean <optional>
include highlighted source (default:
true)opts.attachHandleBoolean <optional>
attaches inspected handle for further inspection (default:
false)-
handles each with the following properties
- Type
- Array.<Object>
-
handle.msecs timeout specified for the handle
- Type
- Number
-
handle.fn the handle itself
- Type
- function
-
handle.name the name of the function, for anonymous functions this is the name it was assigned to
- Type
- String
-
handle.anonymous true if the function was anonymous
- Type
- Boolean
-
handle.source the raw function source
- Type
- String
-
handle.highlighted the highlighted source
- Type
- String
-
handle.location location information about the handle
- Type
- Object
-
handle.location.file full path to the file in which the handle was defined
- Type
- String
-
handle.location.line line where the handle was defined
- Type
- Number
-
handle.location.column column where the handle was defined
- Type
- Number
-
handle.location.inferredName name that is used when function declaration is anonymous
- Type
- String
-
-
Hooks
setIntervalcalls in order to expose the passed handle. NOTE: not needed inio.js >=v1.6.2and will not hook for those versions.The handle is wrapped. In older node versions it is not exposed. The hooked version of
setIntervalwill expose the wrapped callback so its information can be retrieved later.- Source:
-
Convenience function that first calls @see activeHandles and prints the information to stdout.
Name Type Argument Description optionsObject opts.highlightBoolean <optional>
print highlighted source (default:
true)
generated with docme
A core module which depends only on function-origin can be used. It behaves exactly like the main module except
that it doesn't merge opts with default options and provides no highlighting even if highlight is set in the options.
Additionally it does not include the print feature.
You can use it as follows:
var activeHandles = require('active-handles/core');
activeHandles();MIT

