timed-out

Timeout HTTP/HTTPS requests

MIT 12 个版本
安装
npm install timed-out
yarn add timed-out
pnpm add timed-out
bun add timed-out
README

timed-out

Timeout HTTP/HTTPS requests

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

Usage

import http from 'node:http';
import timedOut from 'timed-out';

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

API

timedout(request, time)

request

Required Type: ClientRequest

The request to watch.

time

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.
版本列表
7.0.0 2025-09-09
6.0.0 2021-04-22
5.0.0 2019-09-08
4.0.1 2017-01-16
4.0.0 2016-12-29
3.1.3 2016-12-29
3.1.2 2016-12-28
3.1.1 2016-12-27
3.1.0 2016-12-14
3.0.0 2016-09-18
2.0.0 2014-12-02
1.0.0 2014-11-21