Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

active-handles

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

active-handles

Prints out information about the process's active handles, including function source and location

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

active-handles build status

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();

assets/mixed.png

Shows handles of multiple types created via examples/mixed.js

Installation

npm install active-handles

Caveats

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.

API

activeHandles(options) → {Array.<Object>}

Gathers information about all currently active handles. Active handles are obtained via process._getActiveHandles and location and name of each is resolved.

Parameters:
NameTypeArgumentDescription
options Object
opts.handles Array.<Object>= <optional>

handles to get info for (default: process._getActiveHandles())

opts.source Boolean <optional>

include source (default: true), included either way if highlight=true

opts.highlight Boolean <optional>

include highlighted source (default: true)

opts.attachHandle Boolean <optional>

attaches inspected handle for further inspection (default: false)

Source:
Returns:
  • 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
activeHandles::hookSetInterval()

Hooks setInterval calls in order to expose the passed handle. NOTE: not needed in io.js >=v1.6.2 and will not hook for those versions.

The handle is wrapped. In older node versions it is not exposed. The hooked version of setInterval will expose the wrapped callback so its information can be retrieved later.

Source:
activeHandles::print(options)

Convenience function that first calls @see activeHandles and prints the information to stdout.

Parameters:
NameTypeArgumentDescription
options Object
opts.highlight Boolean <optional>

print highlighted source (default: true)

Source:

generated with docme

core

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();

License

MIT

Keywords

FAQs

Package last updated on 10 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc