Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including timed-out with all npm packages installed. Try it out:

var timedOut = require("timed-out")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

timed-out v5.0.0

Timeout HTTP/HTTPS requests

timed-out Build Status

Timeout HTTP/HTTPS requests

Emits Error object with code property equal ETIMEDOUT or ESOCKETTIMEDOUT when ClientRequest is hanged.


const timedOut = require('timed-out');
const http = require('http');
const timedOut = require('timed-out');

const request = http.get('');
timedOut(request, 2000); // Sets a 2 seconds limit


timedout(request, time)


Required Type: ClientRequest

The request to watch.


Required Type: number | object

Time in milliseconds to wait for a connect event on the socket and also time to wait on inactive socket.

Or you can pass an object with the following fields:

  • connect - Time to wait for a connection.
  • socket - Time to wait for activity on the socket.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free