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
muslnode 18–226 runs
build_error
glibcnode 18–226 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.fixConsider 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()`.fixEnsure 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.fixPrefer 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).
fixRename 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.
fixEnsure 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.
Audit
Dependencies
No dependency data recorded yet.