Gathering detailed insights and metrics for connect-timeout
Gathering detailed insights and metrics for connect-timeout
Gathering detailed insights and metrics for connect-timeout
Gathering detailed insights and metrics for connect-timeout
@types/connect-timeout
TypeScript definitions for connect-timeout
@nest-middlewares/connect-timeout
NestJS Middleware for Connect Timeout
@ryancavanaugh/connect-timeout
Type definitions for connect-timeout from https://www.github.com/DefinitelyTyped/DefinitelyTyped
@uzitech/connect-timeout
Request timeout middleware for Connect/Express
npm install connect-timeout
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
319 Stars
142 Commits
51 Forks
14 Watchers
12 Branches
30 Contributors
Updated on Jun 30, 2025
Latest Version
1.9.0
Package Id
connect-timeout@1.9.0
Size
4.54 kB
NPM Version
3.10.10
Node Version
6.10.3
Published on
May 17, 2017
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Times out a request in the Connect/Express application framework.
This is a Node.js module available through the
npm registry. Installation is done using the
npm install
command:
1$ npm install connect-timeout
NOTE This module is not recommend as a "top-level" middleware (i.e.
app.use(timeout('5s'))
) unless you take precautions to halt your own
middleware processing. See as top-level middleware
for how to use as a top-level middleware.
While the library will emit a 'timeout' event when requests exceed the given timeout, node will continue processing the slow request until it terminates. Slow requests will continue to use CPU and memory, even if you are returning a HTTP response in the timeout callback. For better control over CPU/memory, you may need to find the events that are taking a long time (3rd party HTTP requests, disk I/O, database calls) and find a way to cancel them, and/or close the attached sockets.
Returns middleware that times out in time
milliseconds. time
can also
be a string accepted by the ms
module. On timeout, req
will emit "timeout"
.
The timeout
function takes an optional options
object that may contain
any of the following keys:
Controls if this module will "respond" in the form of forwarding an error.
If true
, the timeout error is passed to next()
so that you may customize
the response behavior. This error has a .timeout
property as well as
.status == 503
. This defaults to true
.
Clears the timeout on the request. The timeout is completely removed and will not fire for this request in the future.
true
if timeout fired; false
otherwise.
Because of the way middleware processing works, once this module passes the request to the next middleware (which it has to do in order for you to do work), it can no longer stop the flow, so you must take care to check if the request has timedout before you continue to act on the request.
1var bodyParser = require('body-parser') 2var cookieParser = require('cookie-parser') 3var express = require('express') 4var timeout = require('connect-timeout') 5 6// example of using this top-level; note the use of haltOnTimedout 7// after every middleware; it will stop the request flow on a timeout 8var app = express() 9app.use(timeout('5s')) 10app.use(bodyParser()) 11app.use(haltOnTimedout) 12app.use(cookieParser()) 13app.use(haltOnTimedout) 14 15// Add your routes here, etc. 16 17function haltOnTimedout (req, res, next) { 18 if (!req.timedout) next() 19} 20 21app.listen(3000)
1var express = require('express') 2var bodyParser = require('body-parser') 3var timeout = require('connect-timeout') 4 5var app = express() 6app.post('/save', timeout('5s'), bodyParser.json(), haltOnTimedout, function (req, res, next) { 7 savePost(req.body, function (err, id) { 8 if (err) return next(err) 9 if (req.timedout) return 10 res.send('saved as id ' + id) 11 }) 12}) 13 14function haltOnTimedout (req, res, next) { 15 if (!req.timedout) next() 16} 17 18function savePost (post, cb) { 19 setTimeout(function () { 20 cb(null, ((Math.random() * 40000) >>> 0)) 21 }, (Math.random() * 7000) >>> 0) 22} 23 24app.listen(3000)
1var bodyParser = require('body-parser') 2var connect = require('connect') 3var timeout = require('connect-timeout') 4 5var app = connect() 6app.use('/save', timeout('5s'), bodyParser.json(), haltOnTimedout, function (req, res, next) { 7 savePost(req.body, function (err, id) { 8 if (err) return next(err) 9 if (req.timedout) return 10 res.send('saved as id ' + id) 11 }) 12}) 13 14function haltOnTimedout (req, res, next) { 15 if (!req.timedout) next() 16} 17 18function savePost (post, cb) { 19 setTimeout(function () { 20 cb(null, ((Math.random() * 40000) >>> 0)) 21 }, (Math.random() * 7000) >>> 0) 22} 23 24app.listen(3000)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
project has 6 contributing companies or organizations
Details
Reason
no dangerous workflow patterns detected
Reason
update tool detected
Details
Reason
license file detected
Details
Reason
all dependencies are pinned
Details
Reason
security policy file detected
Details
Reason
GitHub workflow tokens follow principle of least privilege
Details
Reason
0 existing vulnerabilities detected
Reason
SAST tool detected but not run on all commits
Details
Reason
2 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 2
Reason
branch protection not enabled on development/release branches
Details
Reason
0 out of 2 merged PRs checked by a CI test -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
Found 2/30 approved changesets -- score normalized to 0
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-07-08T07:29:35Z
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More