Skip to content

lmammino/node-blocked

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

blocked

Check if a node event loop is blocked.

If You're running Node.js 8+ you can get a stacktrace pointing to the blocking function using very similar blocked-at package.

Installation

$ npm install blocked

Description

The blocked() function reports every value over the configured threshold (defaulted to 10ms). You can then do whatever you want with that value, graph it, log it, alert, etc.

The process won't be kept open through this.

Params and return value

var timer = blocked(fn, options);
  • fn: The callback function to execute when the event loop is blocked. Will send in the amnount of time in ms that the event loop was blocked.
  • options: Optional. Options object to configure the behaviour. For now, only the threshold option is supported. It determines the amount of ms used to determine if the function callback should be executed; useful to speed up tests
blocked(function(ms) {
    console.log("Blocked");
}, {threshold:1});

Returns: A reference to the timer. Useful for clearing the timer.

var timer = blocked(function(ms) {
                console.log("Blocked");
            });
clearInterval(timer);

License

MIT

About

Check if the event loop is blocked

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%