Launch Week Day 1: Socket for Jira Is Now Available.Learn More
Socket
Book a DemoSign in
Socket

event-loop-inspector

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

event-loop-inspector

Dump event loop data.

latest
npmnpm
Version
1.2.2
Version published
Weekly downloads
6.1K
5.06%
Maintainers
1
Weekly downloads
 
Created
Source
Event loop inspector


npm version

Purpose

Dump event loop data. Useful to known which processes are running and potentially block your application. Can be used for real time monitoring also.

It basically call core NodeJs functions _getActiveHandles and _getActiveRequests to inspect event loop's state.

No dependency.

Compatibility

Supported and tested : >= 4.x Not supported but should work : 0.12.x

VersionSupportedTested
9.xyesyes
8.xyesyes
7.xyesyes
6.xyesyes
4.xyesyes
0.12.xnoyes( manually)
> 0.12.xnono

Installation

$ npm install event-loop-inspector --save

Usage

Basic usage

const inspector = require('event-loop-inspector')();
const dump = inspector.dump();

console.log(dump);

Output

{
  handles:
      {
        setTimeout:
            [{
              type: 'setTimeout',
              startAfter: 311,
              name: 'anonymous',
              msecs: 2000
            }],
        Server:
            [{
              type: 'Server',
              address: '::',
              port: 8000,
              listeners: [{name: 'connectionListener'}]
            }],
        Socket:
            [{
              type: 'Socket',
              localAddress: '127.0.0.1',
              localPort: 45014,
              remoteAddress: '127.0.0.1',
              remotePort: 8000,
              remoteFamily: 'IPv4',
              method: 'GET',
              path: '/toto',
              headers: {host: '127.0.0.1:8000'},
              listeners: []
            }]
      },
  requests:
      {
        TCPConnectWrap:
            [{
              type: 'TCPConnectWrap',
              address: 'xxx.xxx.xxx.xxx',
              port: xxxx,
              localAddress: 'xxx.xxx.xxx.xxx',
              localPort: xxxx
            }]
      },
  setImmediates:
      [
        {type: 'setImmediate', name: 'setImmediateTest2'},
        {type: 'setImmediate', name: 'anonymous'}
      ],
  nextTicks:
      [
        {type: 'nextTick', name: 'afterWrite'},
        {type: 'nextTick', name: 'anonymous'}
      ]
}

Inspect more functions

By default setImmediates and process.nextTick can't be retrieved with functions _getActiveHandles/_getActiveRequests. If you want to allow event-loop-inspector to wrap some core functions, instantiate inspector with first argument set as true.

const inspector = require('event-loop-inspector')(true);
const dump = inspector.dump();

console.log(dump);

Functions that can be wrapped :

  • process.nextTick
  • setImmediate

/!\ Enabling this option may lower performance of the functions involved.

Test

$ npm test

To generate coverage :

$ npm run test-coverage

Coverage report can be found in coverage/.

Keywords

event-loop

FAQs

Package last updated on 18 Sep 2018

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