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

cnysa

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cnysa

A tool for understanding async-hooks

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
Maintainers
1
Weekly downloads
 
Created
Source

cnysa (unpronouncible) is a module that allows you to see information about what the async_hooks module is doing under the covers.

Pre-Require Hook

Pre-require cynsa/register in your application:

node --require cynsa/register app.js

If cnysa.json exists in the current working directory, it will be used as the configuration passed to the Cnysa constructor as described below.

API

const { Cnysa } = require('cnysa');

new Cnysa(options)

All options are optional.

  • options.typeFilter: String or RegExp to use as a filter for AsyncResource types.

Cnysa#enable()

Starts emitting output.

Cnysa#disable()

Stops emitting output.

Understanding output

For each init, before, promiseResolve, and destroy event, a line will be printed.

Each of those lines start with a symbol:

  • + Init
  • * Before
  • - Destroy
  • : Promise Fulfillment

The number that follows is the current time in seconds, mod 1000. This number might be useful in distinguishing "clusters" of async events.

A string after represents the async resource type.

After that, you get a list of numbers delimited by :. The first number is the uid passed in to the corresponding hook, and subsequent numbers follow its triggerAsyncId chain.

For before lines, you'll also see the current execution ID (ex), trigger ID (tr), and an opening brace.

before-after pairs are visualized as indents. A closing brace indicates an after event emission.

Examples

node --require cnysa/register -e "fs.readFile('package.json', (err, contents) => { console.log('done reading') })"
(sleep 2 && curl localhost:8080) & node --require cnysa/register -e "http.createServer((req, res) => res.send('hi')).listen(8080)"

https://gist.github.com/kjin/a499bfcb7c5e12a80f8c6ad66a30b740

Keywords

FAQs

Package last updated on 03 Feb 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

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