request-debug is a Node.js utility library designed to monitor and debug HTTP(S) requests made by the now-deprecated `request` module. It provides an easy way to intercept and log request headers, bodies (for POST), response headers, response bodies (if a callback is provided to `request`), redirects, and authentication challenges. The current stable version is 0.2.0, and due to its dependency on the unmaintained `request` library, its release cadence is effectively none, making it an abandoned project. Its key differentiator was its tight integration with `request`, patching the module instance directly to emit detailed event data for each request lifecycle stage, either to stderr or via a user-defined callback function.
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.
This package is CommonJS-only. Using ES module `import` syntax will result in errors.
const requestDebug = require('request-debug');
The debugging functionality is activated by immediately invoking the required module with the `request` instance as an argument. Omitting `(request)` will not enable debugging.
require('request-debug')(request);
A custom handler must be a function provided as the second argument. It receives `type`, `data`, and the `Request` instance `r`.
require('request-debug')(request, function(type, data, r) { console.log(type, data); });
This example demonstrates how to enable `request-debug` and make a sample HTTP request with basic authentication to an external service (`httpbin.org`), showing how the debug events are logged to the console (stderr by default). It includes a commented-out custom handler example.
const request = require('request');
const util = require('util');
// Enable request-debug, sending output to stderr by default
require('request-debug')(request);
// Alternatively, provide a custom handler function:
// require('request-debug')(request, function(type, data, r) {
// console.error(`[${type.toUpperCase()}] debugId: ${data.debugId}`);
// console.error(util.inspect(data, { colors: true, depth: 3 }));
// });
console.log('Making a debuggable HTTP request...');
request({
uri : 'https://httpbin.org/digest-auth/auth/user/pass',
auth : {
user : 'user',
pass : 'pass',
sendImmediately : false
},
// IMPORTANT: rejectUnauthorized is only for example purposes to ignore self-signed certs
// Do NOT use in production with untrusted certs.
rejectUnauthorized : process.env.NODE_ENV !== 'production' ? false : true,
headers: {
'User-Agent': 'request-debug-example'
}
}, function(err, res, body) {
if (err) {
console.error('Request failed:', err.message);
} else {
console.log('REQUEST RESULTS:');
console.log(' Status Code:', res.statusCode);
console.log(' Body:', body.substring(0, 100) + '...');
}
// Stop debugging once the process is complete (optional)
if (request.stopDebugging) {
request.stopDebugging();
}
});
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.