
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
http-duration-client
Advanced tools
Measure duration (in milliseconds) for Node HTTP
lifecycle events from various phases of HTTP:
git clone git@github.com:congruencelabs/http-duration-client.git
yarn
yarn install
examples/client-with-duration.js
file to see the lifecycle events being logged for a request to https://api.github.com/users
http-duration-client
using npm
or yarn
npm install http-duration-client
or
yarn add http-duration-client
const { requestWithDuration } = require('http-duration-client');
requestWithDuration({
url: "https://api.github.com/users",
headers: {
'User-Agent': 'Example'
},
timeout: 500
}), (err, res) => {
if(err) {
console.error(err);
} else {
console.log(res.duration);
}
});
The result of the above should look similar to
{
"dnsLookup": 62.253469,
"tcpConnection": 20.589025,
"tlsHandshake": 44.643525,
"firstByte": 490.091997,
"contentTransfer": 15.480998,
"total": 633.059014
}
You can also use it with async
and await requestWithDuration()
or requestWithDuration().then()
(async () => {
try {
const resp = await requestWithDuration(
{
url: "https://api.github.com/users",
headers: {
"User-Agent": "Example"
},
timeout: 500
},
);
console.log(resp.duration)
} catch(err) {
console.error(err)
}
})()
The result of the above should look similar to
{
"dnsLookup": 62.253469,
"tcpConnection": 20.589025,
"tlsHandshake": 44.643525,
"firstByte": 490.091997,
"contentTransfer": 15.480998,
"total": 633.059014
}
FAQs
Measure duration for Node HTTP lifecycle events
We found that http-duration-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.