Skip to content

Instantly share code, notes, and snippets.

@DanWahlin
Created February 24, 2017 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanWahlin/59bfe87bb17562ba0ef6974d366f2caa to your computer and use it in GitHub Desktop.
Save DanWahlin/59bfe87bb17562ba0ef6974d366f2caa to your computer and use it in GitHub Desktop.
Monitor Node Event Loop
//*********************************************************
// Quick and dirty way to detect event loop blocking
//*********************************************************
var lastLoop = Date.now();
function monitorEventLoop() {
var time = Date.now();
if (time - lastLoop > 1000) console.error('Event loop blocked ' + (time - lastLoop));
lastLoop = time;
setTimeout(monitorEventLoop, 200);
}
if (process.env.NODE_ENV === 'development') {
monitorEventLoop();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment