Gathering detailed insights and metrics for @uzitech/connect-timeout
Gathering detailed insights and metrics for @uzitech/connect-timeout
Gathering detailed insights and metrics for @uzitech/connect-timeout
Gathering detailed insights and metrics for @uzitech/connect-timeout
npm install @uzitech/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
166 Commits
2 Watchers
3 Branches
1 Contributors
Updated on Oct 14, 2020
Latest Version
1.9.2
Package Id
@uzitech/connect-timeout@1.9.2
Unpacked Size
13.16 kB
Size
4.95 kB
File Count
5
NPM Version
6.14.8
Node Version
12.16.1
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.
Resets the timeout on the request. The timeout is reset to the time
given.
Adds to the timeout on the request. The timeout is increased by the time
given.
Get the current timeout remaining (in milliseconds).
true
if timeout fired; false
otherwise. This will remain true
if the timeout was changed after timeout was fired.
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
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/28 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
22 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
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