Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

timed-out

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timed-out - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

license

28

index.js
'use strict';
module.exports = function (req, time) {
if (req.timeoutTimer) { return req; }
if (req.timeoutTimer) {
return req;
}

@@ -15,9 +17,15 @@ var host = req._headers ? (' to ' + req._headers.host) : '';

// Set additional timeout on socket - in case if remote
// server freeze after sending headers
req.setTimeout(time, function socketTimeoutHandler() {
req.abort();
var e = new Error('Socket timed out on request' + host);
e.code = 'ESOCKETTIMEDOUT';
req.emit('error', e);
// Clear the connection timeout timer once a socket is assigned to the
// request and is connected. Abort the request if there is no activity
// on the socket for more than `time` milliseconds.
req.on('socket', function assign(socket) {
socket.on('connect', function connect() {
clear();
socket.setTimeout(time, function socketTimeoutHandler() {
req.abort();
var e = new Error('Socket timed out on request' + host);
e.code = 'ESOCKETTIMEDOUT';
req.emit('error', e);
});
});
});

@@ -32,5 +40,3 @@

return req
.on('response', clear)
.on('error', clear);
return req.on('error', clear);
};
{
"name": "timed-out",
"version": "2.0.0",
"version": "3.0.0",
"description": "Emit `ETIMEDOUT` or `ESOCKETTIMEDOUT` when ClientRequest is hanged",

@@ -15,3 +15,3 @@ "license": "MIT",

"scripts": {
"test": "mocha"
"test": "xo && mocha"
},

@@ -34,4 +34,5 @@ "files": [

"devDependencies": {
"mocha": "*"
"mocha": "*",
"xo": "^0.16.0"
}
}

@@ -33,3 +33,3 @@ # timed-out [![Build Status](https://travis-ci.org/floatdrop/timed-out.svg?branch=master)](https://travis-ci.org/floatdrop/timed-out)

Time in milliseconds before errors will be emitted and `request.abort()` call happens.
Time in milliseconds to wait for `connect` event on socket and also time to wait on inactive socket.

@@ -36,0 +36,0 @@ ## License

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc