async-hooks is the nodejs api that provides an API to register callbacks tracking the lifetime of asynchronous resources created inside a Node.js application.

In Nodejs app your want to find out resources lifetime about created and destroyed. you can use async-hooks-logger and it is convenient to touch resources lifetime.

Usage

const asyncHooks = require(‘async-hooks-logger’);

const fs = require(‘fs’);

asyncHooks.create(data => {

fs.writeSync(1, `async_hooks: ${JSON.stringify(data)}

`);

});

Structure

{

“asyncId”: 79,

“triggerAsyncId”: 29,

“type”: “HTTPPARSER”,

“isRelease”: true,

“startTime”: 1522663778957,

“endTime”: 1522663898959,

“duration”: 120002

}

you can use duration to finger out the resources lifetime.

Deveop



cd async-hooks-logger

npm run dev git clone git@github.com :stephenkingsley/async-hooks-logger.gitcd async-hooks-loggernpm run dev

and your will see something in the iTerm!