Registry /
http-networking / express-timeout-handler
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
timeoutHandler
✓ const timeout = require('express-timeout-handler');
✗ import timeout from 'express-timeout-handler';
Package is CommonJS-only; no ES module version. Use require.
handler
✓ app.use(timeout.handler(options));
✗ app.use(timeout(options));
Must call timeout.handler(), not timeout directly.
set
✓ timeout.set(4000);
✗ app.use(timeout.set(4000));
timeout.set() returns route-specific middleware; do not call on app level.
Demonstrates default global timeout and per-route override with timeout.set(), including onTimeout callback.
const express = require('express');
const timeout = require('express-timeout-handler');
const app = express();
const options = {
timeout: 5000,
onTimeout: function(req, res) {
res.status(503).send('Service unavailable. Please retry.');
},
onDelayedResponse: function(req, method, args, requestTime) {
console.log('Delayed response after timeout:', method);
},
disable: ['write', 'send', 'json', 'end']
};
app.use(timeout.handler(options));
app.get('/greet', function (req, res) {
setTimeout(() => res.send('Hello'), 6000); // Will timeout
});
app.get('/leave', timeout.set(2000), function (req, res) {
setTimeout(() => res.send('Goodbye'), 1000);
});
app.listen(3000, () => console.log('running'));
Errors
Common errors & fixes
TypeError: timeout.handler is not a function
Using import ES module syntax on a CommonJS package; or incorrect import path.
fixUse require('express-timeout-handler'). TimeoutError: The response object was ended after the request timed out
onTimeout did not send a response, or another middleware called res.send after timeout.
fixEnsure onTimeout calls res.end() or similar; check disable array if too restrictive.
Cannot set property 'globalTimeout' of undefined
timeout.handler(options) was attached before Express app initialization or on non-request object.
fixCall app.use(timeout.handler(options)) after express() and before routes.
Audit
Dependencies
expressrequiredpeer dependency: designed as Express middleware, requires Express app instance