Registry / http-networking / http-measuring-client

http-measuring-client

JSON →
library1.0.1jsnpmunverified

The `http-measuring-client` is a Node.js module, currently at version 1.0.1, designed to provide detailed timing statistics for outbound HTTP and HTTPS requests. Released around 2014, the project appears to be unmaintained, with its last copyright year being 2014, indicating an abandoned status. It offers a drop-in replacement for Node's native `http` and `https` modules, emitting a 'stat' event with granular timing data such as `totalTime`, `connectionTime`, `processingTime`, and `transmittingTime` (all in milliseconds) after each request completes. This allows developers to gain insight into network latency and server response times directly from the client without requiring external proxies. While it can integrate with popular HTTP clients like `request` and `superagent` by injecting its custom HTTP module, it also supports a less recommended global monkey-patching approach for broader coverage. Its primary differentiator is the direct integration into the HTTP client layer for metrics collection.

npm install http-measuring-client
INSTALL
IMPORT
SIG · HTTP-MEASURING-CLI
H
http-measuring-client
http-networkingjavascriptv1.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

create
const httpMeasuringClient = require('http-measuring-client'); const http = httpMeasuringClient.create();
import { create } from 'http-measuring-client';
This package is CommonJS only and does not support ES module `import` syntax.
createSecure
const httpMeasuringClient = require('http-measuring-client'); const https = httpMeasuringClient.createSecure();
import { createSecure } from 'http-measuring-client';
Used for instrumenting the Node.js native `https` module. CommonJS only.
mixin
const httpMeasuringClient = require('http-measuring-client'); httpMeasuringClient.mixin(require('http'));
import { mixin } from 'http-measuring-client';
Allows monkey-patching the global Node.js `http` module, though the documentation advises against this approach. CommonJS only.

This example demonstrates how to create a measuring HTTP client, listen for 'stat' events to log detailed timing information, and make both HTTP and HTTPS requests.

const httpMeasuringClient = require('http-measuring-client'); const http = httpMeasuringClient.create(); http.on('stat', (parsedUri, stats) => { console.log(`Request to ${parsedUri.href} completed.`); console.log(`Total Time: ${stats.totalTime}ms`); console.log(`Connection Time: ${stats.connectionTime}ms`); console.log(`Processing Time: ${stats.processingTime}ms`); console.log(`Transmitting Time: ${stats.transmittingTime}ms`); }); // Make an HTTP GET request and collect stats http.get('http://google.com', (response) => { let data = ''; response.on('data', (chunk) => { data += chunk; }); response.on('end', () => { console.log('Response from google.com received and ended.'); // console.log('Response body snippet:', data.substring(0, 100) + '...'); }); }).on('error', (err) => { console.error('Error during HTTP request:', err.message); }); // Example with an HTTPS request (requires a different client instance) const https = httpMeasuringClient.createSecure(); https.get('https://example.com', (response) => { response.on('data', () => {}); response.on('end', () => { console.log('Response from example.com received.'); }); }).on('error', (err) => { console.error('Error during HTTPS request:', err.message); });
Debug
Known issues
breakingThe `http-measuring-client` package is abandoned and has not been updated since 2014. It is unlikely to be compatible with recent Node.js versions, especially those introducing significant changes to the `http` module or new APIs like `fetch` and `http2`. Using unmaintained packages poses security risks and may lead to unexpected behavior.
fix
Consider using modern, actively maintained HTTP client libraries with built-in or plugin-based metric collection, such as `axios` with interceptors, `node-fetch` with custom agents, or OpenTelemetry integrations for Node.js.
affects: >=1.0.1 (all versions)
gotchaThe package is CommonJS-only. Attempting to use `import` statements (ES modules) will result in a `ReferenceError: require is not defined` or similar errors in an ES module context. It must be consumed via `require()`.
fix
Ensure your project is configured for CommonJS, or use `const httpMeasuringClient = require('http-measuring-client');` in an ES module file to import it if your Node.js version supports mixing CJS and ESM.
affects: >=1.0.1 (all versions)
gotchaThe documentation explicitly states that monkey-patching the global `http` module using `.mixin(http)` is possible but 'not recommended'. This approach can lead to unforeseen side effects, conflicts with other modules, and make debugging difficult due to altering global behavior.
fix
Prefer creating and injecting `http-measuring-client` instances into specific HTTP client libraries (like `request.defaults({ httpModules: { 'http:': http } })`) rather than modifying global modules.
affects: >=1.0.1 (all versions)
Errors
Common errors & fixes
ReferenceError: require is not defined in ES module scope
Attempting to use `require('http-measuring-client')` in a file that is treated as an ES module (e.g., because of `"type": "module"` in `package.json` or `.mjs` extension).
fix
Rename your file to `.cjs`, or change your `package.json`'s `type` field to `"commonjs"`. Alternatively, use `import { createRequire } from 'module'; const require = createRequire(import.meta.url); const httpMeasuringClient = require('http-measuring-client');` if you must use it within an ESM file.
TypeError: http.get is not a function (or similar 'not a function' error on http methods)
This error can occur if the `http-measuring-client` is not correctly initialized with a valid `http` module, or if a global monkey-patching attempt failed or was overwritten.
fix
Ensure you are calling `httpMeasuringClient.create()` or `httpMeasuringClient.createSecure()` and assigning the result to a variable that you then use for making requests (e.g., `const http = httpMeasuringClient.create(); http.get(...)`). Verify no other module is interfering with the `http` object.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
2
Resources
http-measuring-client — npm install http-measuring-client · libregistry