node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



Build Status

npm install debug-middleware

Log middleware that does not complete within an allotted amount of time


debug(app, [timeout])


  • app - an express app
  • timeout (optional) Number - Milliseconds to wait for request handlers and middleware to complete. Defaults to 5000.

Call the middleware debugger after all of your middleware and routes have been defined.

var express         = require('express');
var app             = express();
var debugMiddleware = require('debug-middleware');
function slowMiddleware(req, res, next) {
  setTimeout(function() {
  }, 6000);
app.get('/', slowMiddleware, function(req, res, next) {
app.on('listening', function() {


The following items will be included in the log output:

  • The request method
  • The request host
  • The request path
  • The middleware function as a one-line string

Example output:

A route middleware took too long to execute: function slowMiddleware(req, res, next) {\n  setTimeout(function() {\n    next();\n  }, 6000);\n}