Superagent HTTP Timings Plugin for Node.js

1.0.2 · active · verified Wed Apr 22

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.

Common errors

Warnings

Install

Imports

Quickstart

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.

const request = require('superagent');
const logNetworkTime = require('superagent-node-http-timings');

async function makeTimedRequest() {
  try {
    const response = await request
      .get(`https://google.com`)
      .use(logNetworkTime((err, result) => {
        if (err) {
          console.error('Timing error:', err);
          return;
        }
        console.log('HTTP Timings:', result);
      }));
    console.log('Request completed with status:', response.status);
  } catch (error) {
    console.error('Request failed:', error.message);
  }
}

makeTimedRequest();

view raw JSON →