Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
The 'timed-out' npm package is used to timeout HTTP requests. It provides a simple way to set timeouts for various stages of an HTTP request, such as the connection, socket, and response stages.
Set timeout for HTTP request
This feature allows you to set a timeout for an HTTP request. In this example, a timeout of 5 seconds is set for the HTTP GET request to 'http://example.com'. If the request takes longer than 5 seconds, it will be aborted.
const http = require('http');
const timedOut = require('timed-out');
const req = http.get('http://example.com', (res) => {
// Handle response
});
// Set a timeout of 5 seconds
const timeout = 5000;
timedOut(req, timeout);
Set timeout for specific stages
This feature allows you to set timeouts for specific stages of an HTTP request. In this example, different timeouts are set for the connection, socket, and response stages of the HTTP GET request to 'http://example.com'.
const http = require('http');
const timedOut = require('timed-out');
const req = http.get('http://example.com', (res) => {
// Handle response
});
// Set timeouts for different stages
const options = {
connect: 1000, // 1 second for connection
socket: 2000, // 2 seconds for socket
response: 3000 // 3 seconds for response
};
timedOut(req, options);
Axios is a promise-based HTTP client for the browser and Node.js. It allows you to set timeouts for requests and provides a more comprehensive set of features for making HTTP requests compared to 'timed-out'.
Request is a simplified HTTP client that supports timeouts and many other features. It is more feature-rich than 'timed-out' and provides a higher-level API for making HTTP requests.
Got is a human-friendly and powerful HTTP request library for Node.js. It supports timeouts and provides a more modern and flexible API compared to 'timed-out'.
Timeout HTTP/HTTPS requests
Emits Error object with code
property equal ETIMEDOUT
or ESOCKETTIMEDOUT
when ClientRequest is hanged.
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
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.Available as part of the Tidelift Subscription.
The maintainers of timed-out and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.
FAQs
Timeout HTTP/HTTPS requests
The npm package timed-out receives a total of 4,013,942 weekly downloads. As such, timed-out popularity was classified as popular.
We found that timed-out demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.