superagent-node-http-timings is a superagent plugin designed for Node.js environments to capture detailed HTTP request timing information. It provides granular metrics such as `socketAssigned`, `dnsLookup`, `tcpConnection`, `tlsHandshake`, `firstByte`, and `contentTransfer`, culminating in a `total` request duration. This allows developers to monitor and optimize network performance in Node.js applications, similar to a browser's network inspector. The current stable version is `1.0.2`, with recent updates addressing issues like HTTP keep-alive. While not a high-cadence package, it receives targeted fixes as needed, indicating active maintenance. Its key differentiator is providing a comprehensive breakdown of network timings specifically integrated into the `superagent` request flow for server-side environments.
npm install superagent-node-http-timingsVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use the superagent-node-http-timings plugin to log detailed HTTP network timings for a GET request to google.com.
For ESM, use `import logNetworkTime from 'superagent-node-http-timings';`
Install superagent: `npm install superagent` or `yarn add superagent`.
Handle errors explicitly within the callback: `logNetworkTime((err, result) => { if (err) { console.error(err); return; } ... });`For ESM, use `import logNetworkTime from 'superagent-node-http-timings';` and ensure your `package.json` has `"type": "module"` or the file uses the `.mjs` extension.
Ensure you are directly importing the default export: `import logNetworkTime from 'superagent-node-http-timings';`
Install superagent: `npm install superagent` or `yarn add superagent`.