nhanelon
v1.2.2
Published
nhanelon detector for Node.js
Downloads
11
Readme
Hang detector for Node.js
This is a simple package to detect hangs in Node.js applications caused by infinite loop or any other reason that causes the main thread to block.
nhanelon starts a worker thread that expects to continuously receive ping messages from the main thread. If these messages stop coming, then it is considered a hang.
Installation
$ npm install nhanelon
Usage
const { watch, unwatch } = require('nhanelon');
// Start watch
watch({ checkInterval: 5000, pingInterval: 1000 });
By default, when a hang is detected, the process will be aborted. Perhaps you are using a process manager like pm2 which will restart your application.
Options
checkInterval
A time delay between each function call in the Worker thread that checks if the main thread is blockedpingInterval
A time delay between each function call in the main thread that sends ping messages to the Worker threadscript
An optional path to the script that is loaded in the Worker thread to handle the hang. The script must exportonHang
function that will be called in the context of the worker thread when a hang is detected. If the script is not set, then the application will simply be terminated.